From 6138770ef216d3e2008eb270d542edb88c5701c4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 28 Apr 2021 12:02:52 +0200 Subject: [PATCH] Gui: [skip ci] fix crash in SequencerBar::setProgress or SequencerDialog::setProgress when used in worker threads --- src/Gui/ProgressBar.cpp | 10 +++++++++- src/Gui/ProgressDialog.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index fcaff6adb5..9225d24bf3 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -226,7 +226,15 @@ void SequencerBar::nextStep(bool canAbort) void SequencerBar::setProgress(size_t step) { - d->bar->show(); + QThread* currentThread = QThread::currentThread(); + QThread* thr = d->bar->thread(); // this is the main thread + if (thr != currentThread) { + QMetaObject::invokeMethod(d->bar, "show", Qt::QueuedConnection); + } + else { + d->bar->show(); + } + setValue((int)step); } diff --git a/src/Gui/ProgressDialog.cpp b/src/Gui/ProgressDialog.cpp index 519ad2e72e..81cec75712 100644 --- a/src/Gui/ProgressDialog.cpp +++ b/src/Gui/ProgressDialog.cpp @@ -152,7 +152,15 @@ void SequencerDialog::nextStep(bool canAbort) void SequencerDialog::setProgress(size_t step) { - d->dlg->show(); + QThread* currentThread = QThread::currentThread(); + QThread* thr = d->dlg->thread(); // this is the main thread + if (thr != currentThread) { + QMetaObject::invokeMethod(d->dlg, "show", Qt::QueuedConnection); + } + else { + d->dlg->show(); + } + setValue((int)step); }