summaryrefslogtreecommitdiff
path: root/src/backend/btinstallthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/btinstallthread.cpp')
-rw-r--r--src/backend/btinstallthread.cpp46
1 files changed, 19 insertions, 27 deletions
diff --git a/src/backend/btinstallthread.cpp b/src/backend/btinstallthread.cpp
index 69e5fb8..b2e7679 100644
--- a/src/backend/btinstallthread.cpp
+++ b/src/backend/btinstallthread.cpp
@@ -2,20 +2,20 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "backend/btinstallthread.h"
+#include "btinstallthread.h"
+#include <memory>
#include <QDebug>
#include <QDir>
#include <QString>
#include <QThread>
-#include "backend/managers/cswordbackend.h"
-
-#include "backend/btinstallbackend.h"
+#include "btinstallbackend.h"
+#include "managers/cswordbackend.h"
// Sword includes:
#include <filemgr.h>
@@ -47,21 +47,14 @@ void BtInstallThread::run() {
return;
}
- m_stopRequestedMutex.lock();
- try {
- for (m_currentModuleIndex = 0;
- !m_stopRequested && (m_currentModuleIndex < m_modules.size());
- m_currentModuleIndex++)
- {
- m_stopRequestedMutex.unlock();
- installModule();
- m_stopRequestedMutex.lock();
- }
- } catch (...) {
- m_stopRequestedMutex.unlock();
- throw;
+ for (m_currentModuleIndex = 0;
+ m_currentModuleIndex < m_modules.size();
+ ++m_currentModuleIndex)
+ {
+ installModule();
+ if (m_stopRequested.load(std::memory_order_relaxed))
+ break;
}
- m_stopRequestedMutex.unlock();
}
void BtInstallThread::installModule() {
@@ -69,22 +62,21 @@ void BtInstallThread::installModule() {
const CSwordModuleInfo * const module = m_modules.at(m_currentModuleIndex);
- sword::InstallSource installSource = BtInstallBackend::source(module->property("installSourceName").toString());
- QScopedPointer<CSwordBackend> backendForSource(BtInstallBackend::backend(installSource));
+ QVariant vModuleName = module->property("installSourceName");
+ QString moduleName = vModuleName.toString();
+ sword::InstallSource installSource = BtInstallBackend::source(moduleName);
+ std::unique_ptr<CSwordBackend> backendForSource(BtInstallBackend::backend(installSource));
// Check whether it's an update. If yes, remove existing module first:
/// \todo silently removing without undo if the user cancels the update is WRONG!!!
- if (!removeModule()) {
- QMutexLocker lock(&m_stopRequestedMutex);
- if (m_stopRequested)
- return;
- }
+ if (!removeModule() && m_stopRequested.load(std::memory_order_relaxed))
+ return;
// manager for the destination path
sword::SWMgr lMgr(m_destination.toLatin1());
if (BtInstallBackend::isRemote(installSource)) {
int status = m_iMgr.installModule(&lMgr,
- 0,
+ nullptr,
module->name().toLatin1(),
&installSource);
if (status == 0) {