diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-06-06 13:40:38 +0200 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-06-06 13:40:38 +0200 |
| commit | 0ad56591fd9581aa9195f854ac3fc1b40d5b1802 (patch) | |
| tree | 75f47a25da8c8045dd195f42c8c218acb425d3db /src/installationmanager.cpp | |
| parent | e49ce3ed21b10b9af21caaabd8c2f1339fe59076 (diff) | |
Fix order of operations to avoid deadlock with event loop.
Diffstat (limited to 'src/installationmanager.cpp')
| -rw-r--r-- | src/installationmanager.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 7f4ad864..9d64a6f3 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -186,25 +186,28 @@ bool InstallationManager::extractFiles(QString extractPath, QString title, bool auto start = std::chrono::system_clock::now(); + // Future watcher to exit the loop: + QFutureWatcher<bool> futureWatcher; + + QEventLoop loop(this); + connect( + &futureWatcher, &QFutureWatcher<bool>::finished, + &loop, &QEventLoop::quit, + Qt::QueuedConnection); + // unpack only the files we need for the installer - QFuture<bool> future = QtConcurrent::run([&]() -> bool { + futureWatcher.setFuture(QtConcurrent::run([&]() -> bool { return m_ArchiveHandler->extract( extractPath.toStdWString(), progressCallback, showFilenames ? fileChangeCallback : nullptr, errorCallback ); - }); - - // Future watcher to exit the loop: - QFutureWatcher<bool> futureWatcher; - futureWatcher.setFuture(future); - - QEventLoop loop(this); - connect(&futureWatcher, &QFutureWatcher<bool>::finished, &loop, &QEventLoop::quit); + })); // Wait for future to complete: loop.exec(); + auto future = futureWatcher.future(); // Check the result: if (!future.result()) { |
