diff options
| author | Al <26797547+Al12rs@users.noreply.github.com> | 2021-01-01 14:49:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-01 14:49:46 +0100 |
| commit | 386cfc511a0d843851d78eeb2bce8d1da725d0d0 (patch) | |
| tree | 138ff676e1fd213b097058b3d4927e001dc7257a /src | |
| parent | edee6af38e431dccefacf73a728d903cffa104b2 (diff) | |
| parent | 469cfcef5593d73975a077b8d25027ba56ccb955 (diff) | |
Merge pull request #1336 from Holt59/fix-crash-during-extraction
Tentative fix for crash during large extraction.
Diffstat (limited to 'src')
| -rw-r--r-- | src/installationmanager.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index e9324b41..413f567a 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -186,19 +186,26 @@ bool InstallationManager::extractFiles(QString extractPath, QString title, bool // Cancelling progress only cancel the extraction, we do not force exiting the event-loop: connect(installationProgress, &QProgressDialog::canceled, [this]() { m_ArchiveHandler->cancel(); }); + std::mutex mutex; int currentProgress = 0; QString currentFileName; // The callbacks: - auto progressCallback = [this, ¤tProgress](auto progressType, uint64_t current, uint64_t total) { + auto progressCallback = [this, ¤tProgress, &mutex](auto progressType, uint64_t current, uint64_t total) { if (progressType == Archive::ProgressType::EXTRACTION) { - currentProgress = static_cast<int>(100 * current / total); + { + std::scoped_lock guard(mutex); + currentProgress = static_cast<int>(100 * current / total); + } emit progressUpdate(); } }; - Archive::FileChangeCallback fileChangeCallback = [this, ¤tFileName](auto changeType, std::wstring const& file) { + Archive::FileChangeCallback fileChangeCallback = [this, ¤tFileName, &mutex](auto changeType, std::wstring const& file) { if (changeType == Archive::FileChangeType::EXTRACTION_START) { - currentFileName = QString::fromStdWString(file); + { + std::scoped_lock guard(mutex); + currentFileName = QString::fromStdWString(file); + } emit progressUpdate(); } }; @@ -222,6 +229,7 @@ bool InstallationManager::extractFiles(QString extractPath, QString title, bool while (!futureWatcher.isFinished()) { loop.processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents); + std::scoped_lock guard(mutex); if (currentProgress != installationProgress->value()) { installationProgress->setValue(currentProgress); } |
