Skip to content

Commit

Permalink
Gui: [skip ci] fix crash in SequencerBar::setProgress or SequencerDia…
Browse files Browse the repository at this point in the history
…log::setProgress when used in worker threads
  • Loading branch information
wwmayer committed Apr 28, 2021
1 parent b5c49a6 commit 6138770
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Gui/ProgressBar.cpp
Expand Up @@ -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);
}

Expand Down
10 changes: 9 additions & 1 deletion src/Gui/ProgressDialog.cpp
Expand Up @@ -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);
}

Expand Down

0 comments on commit 6138770

Please sign in to comment.