From 150080284129872be028175b4d16cdfdac6f0164 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sat, 5 Mar 2022 13:29:42 +0100 Subject: [PATCH 1/2] Fix rare SEGFAULT when closing the progress dialog Happened when aborting a batch operation on multiple tracks. --- src/util/taskmonitor.cpp | 14 +++++++++++++- src/util/taskmonitor.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/util/taskmonitor.cpp b/src/util/taskmonitor.cpp index 633f580fa11..45a53da0d48 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,22 @@ void TaskMonitor::abortAllTasks() { updateProgress(); } +void TaskMonitor::closeProgressDialog() { + DEBUG_ASSERT(m_taskInfos.isEmpty()); + auto* const pProgressDlg = m_pProgressDlg.release(); + // 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. + if (pProgressDlg) { + 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; From fe5583e4342f4a3530ee872c0c94990be495f097 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sat, 5 Mar 2022 22:32:37 +0100 Subject: [PATCH 2/2] Hide the progress dialog immediately --- src/util/taskmonitor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/taskmonitor.cpp b/src/util/taskmonitor.cpp index 45a53da0d48..1e3d48e27a8 100644 --- a/src/util/taskmonitor.cpp +++ b/src/util/taskmonitor.cpp @@ -146,11 +146,12 @@ void TaskMonitor::abortAllTasks() { void TaskMonitor::closeProgressDialog() { DEBUG_ASSERT(m_taskInfos.isEmpty()); - auto* const pProgressDlg = m_pProgressDlg.release(); // 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(); } }