diff options
| author | Silarn <jrim@rimpo.org> | 2018-05-04 14:28:19 -0500 |
|---|---|---|
| committer | Silarn <jrim@rimpo.org> | 2018-05-04 14:28:19 -0500 |
| commit | a77433f8810c100e6934c64afe9d69c6c0cff2f4 (patch) | |
| tree | 98cf908a04f6038f5d702919b5806549d96ad753 | |
| parent | 54e219759283c4805f40c03d2215831081f55d51 (diff) | |
Use queued connections and do while loops to finish event processing
| -rw-r--r-- | src/installationmanager.cpp | 31 | ||||
| -rw-r--r-- | src/installationmanager.h | 1 |
2 files changed, 12 insertions, 20 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index a99a07e1..27c83787 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -96,8 +96,8 @@ InstallationManager::InstallationManager() throw MyException(getErrorString(m_ArchiveHandler->getLastError()));
}
- connect(this, SIGNAL(progressUpdate(float)), this, (SLOT(doProgressUpdate(float))));
- connect(this, SIGNAL(progressUpdate(const QString)), this, (SLOT(doProgressFileUpdate(const QString))));
+ connect(this, SIGNAL(progressUpdate(float)), this, (SLOT(doProgressUpdate(float))), Qt::QueuedConnection);
+ connect(this, SIGNAL(progressUpdate(const QString)), this, (SLOT(doProgressFileUpdate(const QString))), Qt::QueuedConnection);
}
InstallationManager::~InstallationManager()
@@ -202,10 +202,10 @@ bool InstallationManager::unpackSingleFile(const QString &fileName) new MethodCallback<InstallationManager, void, QString const &>(this, &InstallationManager::report7ZipError)
);
});
- while (!future.isFinished()) {
- QCoreApplication::processEvents();
+ do {
::Sleep(50);
- }
+ QCoreApplication::processEvents();
+ } while (!future.isFinished());
bool res = future.result();
return res;
@@ -300,10 +300,10 @@ QStringList InstallationManager::extractFiles(const QStringList &filesOrig, bool new MethodCallback<InstallationManager, void, QString const &>(this, &InstallationManager::report7ZipError)
);
});
- while (!future.isFinished()) {
- QCoreApplication::processEvents();
+ do {
::Sleep(50);
- }
+ QCoreApplication::processEvents();
+ } while (!future.isFinished());
if (!future.result()) {
throw MyException(QString("extracting failed (%1)").arg(m_ArchiveHandler->getLastError()));
}
@@ -444,7 +444,7 @@ void InstallationManager::updateProgressFile(QString const &fileName) void InstallationManager::doProgressUpdate(float percentage)
{
if (m_InstallationProgress != nullptr) {
- QMetaObject::invokeMethod(this, "setProgressValue", Qt::QueuedConnection, Q_ARG(int, static_cast<int>(percentage * 100.0)));
+ m_InstallationProgress->setValue(static_cast<int>(percentage * 100.0));
if (m_InstallationProgress->wasCanceled()) {
m_ArchiveHandler->cancel();
@@ -453,13 +453,6 @@ void InstallationManager::doProgressUpdate(float percentage) }
}
-void InstallationManager::setProgressValue(int percentage)
-{
- if (m_InstallationProgress != nullptr) {
- m_InstallationProgress->setValue(percentage);
- }
-}
-
void InstallationManager::doProgressFileUpdate(QString const fileName)
{
if (m_InstallationProgress != nullptr) {
@@ -616,10 +609,10 @@ bool InstallationManager::doInstall(GuessedValue<QString> &modName, QString game new MethodCallback<InstallationManager, void, QString const &>(this, &InstallationManager::report7ZipError)
);
});
- while (!future.isFinished()) {
- QCoreApplication::processEvents();
+ do {
::Sleep(50);
- }
+ QCoreApplication::processEvents();
+ } while (!future.isFinished());
if (!future.result()) {
if (m_ArchiveHandler->getLastError() == Archive::ERROR_EXTRACT_CANCELLED) {
return false;
diff --git a/src/installationmanager.h b/src/installationmanager.h index 851390a7..84ccd1a4 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -186,7 +186,6 @@ private slots: void doProgressUpdate(float percentage);
void doProgressFileUpdate(const QString fileName);
- void setProgressValue(int percentage);
private:
|
