summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-31 11:51:20 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2020-12-31 11:52:16 +0100
commit469cfcef5593d73975a077b8d25027ba56ccb955 (patch)
tree138ff676e1fd213b097058b3d4927e001dc7257a
parentedee6af38e431dccefacf73a728d903cffa104b2 (diff)
Tentative fix for crash during large extraction.
-rw-r--r--src/installationmanager.cpp16
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, &currentProgress](auto progressType, uint64_t current, uint64_t total) {
+ auto progressCallback = [this, &currentProgress, &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, &currentFileName](auto changeType, std::wstring const& file) {
+ Archive::FileChangeCallback fileChangeCallback = [this, &currentFileName, &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);
}