diff --git a/src/util/taskmonitor.cpp b/src/util/taskmonitor.cpp index 633f580fa11..1e3d48e27a8 100644 --- a/src/util/taskmonitor.cpp +++ b/src/util/taskmonitor.cpp @@ -28,6 +28,7 @@ TaskMonitor::~TaskMonitor() { << "pending tasks"; abortAllTasks(); } + closeProgressDialog(); } Task* TaskMonitor::senderTask() const { @@ -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(std::round(sumEstimatedPercentageOfCompletion())); diff --git a/src/util/taskmonitor.h b/src/util/taskmonitor.h index f10cc2cc8a1..de7cfa287c2 100644 --- a/src/util/taskmonitor.h +++ b/src/util/taskmonitor.h @@ -82,6 +82,7 @@ class TaskMonitor private: Task* senderTask() const; void updateProgress(); + void closeProgressDialog(); const QString m_labelText; const Duration m_minimumProgressDuration;