Skip to content

Commit

Permalink
Merge pull request #4695 from uklotzde/progressdialog-segfault
Browse files Browse the repository at this point in the history
[2.3] Fix rare SEGFAULT when closing the progress dialog
  • Loading branch information
daschuer committed Mar 7, 2022
2 parents 31b8c07 + fe5583e commit 9564ac2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/util/taskmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TaskMonitor::~TaskMonitor() {
<< "pending tasks";
abortAllTasks();
}
closeProgressDialog();
}

Task* TaskMonitor::senderTask() const {
Expand Down Expand Up @@ -143,11 +144,23 @@ void TaskMonitor::abortAllTasks() {
updateProgress();
}

void TaskMonitor::closeProgressDialog() {
DEBUG_ASSERT(m_taskInfos.isEmpty());
// Deleting the progress dialog immediately might cause
// segmentation faults due to pending signals! The deletion
// has to be deferred until re-entering the event loop.
auto* const pProgressDlg = m_pProgressDlg.release();
if (pProgressDlg) {
pProgressDlg->setVisible(false);
pProgressDlg->deleteLater();
}
}

void TaskMonitor::updateProgress() {
DEBUG_ASSERT_MAIN_THREAD_AFFINITY();
DEBUG_ASSERT_QOBJECT_THREAD_AFFINITY(this);
if (m_taskInfos.isEmpty()) {
m_pProgressDlg.reset();
closeProgressDialog();
return;
}
const int currentProgress = static_cast<int>(std::round(sumEstimatedPercentageOfCompletion()));
Expand Down
1 change: 1 addition & 0 deletions src/util/taskmonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class TaskMonitor
private:
Task* senderTask() const;
void updateProgress();
void closeProgressDialog();

const QString m_labelText;
const Duration m_minimumProgressDuration;
Expand Down

0 comments on commit 9564ac2

Please sign in to comment.