diff options
Diffstat (limited to 'src/frontend/bookshelfmanager/installpage/btinstallthread.cpp')
-rw-r--r-- | src/frontend/bookshelfmanager/installpage/btinstallthread.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp index 48e38ce..53ae071 100644 --- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp +++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp @@ -7,23 +7,22 @@ * **********/ -#include "btinstallthread.h" - -#include "frontend/bookshelfmanager/btinstallmgr.h" -#include "frontend/bookshelfmanager/instbackend.h" -#include "util/cpointers.h" -#include "backend/managers/cswordbackend.h" +#include "frontend/bookshelfmanager/installpage/btinstallthread.h" #include <QApplication> +#include <QDebug> +#include <QDir> #include <QString> #include <QThread> -#include <QDir> - -#include <QDebug> +#include "backend/managers/cswordbackend.h" +#include "frontend/bookshelfmanager/btinstallmgr.h" +#include "frontend/bookshelfmanager/instbackend.h" +#include "util/cpointers.h" -// sword +// Sword includes: #include <filemgr.h> + BtInstallThread::BtInstallThread(QObject* parent, QString moduleName, QString sourceName, QString destinationName) : QThread(parent), done(false), @@ -44,12 +43,13 @@ void BtInstallThread::run() { emit preparingInstall(m_module, m_source); - + //This is 0 before set here - remember when using the value when cancelling + // the installation before this has been run m_installSource.reset(new sword::InstallSource(instbackend::source(m_source))); m_backendForSource.reset(instbackend::backend(*m_installSource)); //make sure target/mods.d and target/modules exist - //TODO: move this to some common precondition + /// \todo move this to some common precondition QDir dir(m_destination); if (!dir.exists()) { dir.mkdir(m_destination); @@ -68,7 +68,7 @@ void BtInstallThread::run() { QObject::connect(m_iMgr, SIGNAL(downloadStarted()), this, SLOT(slotDownloadStarted()), Qt::QueuedConnection); //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!!! + /// \todo silently removing without undo if the user cancels the update is WRONG!!! removeModule(); // manager for the destination path @@ -112,35 +112,36 @@ void BtInstallThread::slotStopInstall() { qDebug() << "BtInstallThread::slotStopInstall 2"; //qApp->processEvents(); // wait to terminate for some secs. We rather let the execution go on and cleaning up to fail than the app to freeze - int notRun = this->wait(200); + int notRun = this->wait(25000); if (notRun) { this->terminate(); - this->wait(2); + this->wait(10000); qDebug() << "installthread (" << m_module << ") terminated, delete m_iMgr"; delete m_iMgr; // this makes sure the ftp library will be cleaned up in the destroyer m_iMgr = 0; } qDebug() << "BtInstallThread::slotStopInstall 3"; // cleanup: remove the module, remove the temp files - if (true) { + // if installation has already started + if (m_installSource.get() != 0) { qDebug() << "BtInstallThread::slotStopInstall 4"; // remove the installed module, just to be sure because mgr may // have been terminated when copying files removeModule(); removeTempFiles(); qDebug() << "BtInstallThread::slotStopInstall will emit installStopped..."; - emit installStopped(m_module, m_source); } + emit installStopped(m_module, m_source); } } void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/) { - //qDebug("BtInstallThread::slotManagerStatusUpdated"); + //qDebug() << "BtInstallThread::slotManagerStatusUpdated"; emit statusUpdated(m_module, totalProgress); } void BtInstallThread::slotDownloadStarted() { - qDebug("BtInstallThread::slotDownloadStarted"); + qDebug() << "BtInstallThread::slotDownloadStarted"; emit downloadStarted(m_module); } @@ -176,7 +177,7 @@ void BtInstallThread::removeModule() { } void BtInstallThread::removeTempFiles() { - qDebug("BtInstallThread::removeTempFiles start"); + qDebug() << "BtInstallThread::removeTempFiles start"; // (take the remote conf file for this module, take DataPath, // take the absolute path of the InstallMgr) |