From 76c8fd4d9c376c5eefb216c80398bc9a05a18c30 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Fri, 27 Dec 2024 14:47:11 -0500 Subject: [PATCH] Allow surface generation to be cancelled Fix #1582 Signed-off-by: Geoff Hutchison --- avogadro/qtplugins/surfaces/surfaces.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/avogadro/qtplugins/surfaces/surfaces.cpp b/avogadro/qtplugins/surfaces/surfaces.cpp index 35d0a06254..716c583f0a 100644 --- a/avogadro/qtplugins/surfaces/surfaces.cpp +++ b/avogadro/qtplugins/surfaces/surfaces.cpp @@ -560,7 +560,6 @@ void Surfaces::calculateQM(Type type, int index, bool beta, float isoValue, // TODO: Check to see if this cube or surface has already been computed if (!m_progressDialog) { m_progressDialog = new QProgressDialog(qobject_cast(parent())); - m_progressDialog->setCancelButtonText(nullptr); m_progressDialog->setWindowModality(Qt::NonModal); connectSlots = true; } @@ -629,6 +628,8 @@ void Surfaces::calculateQM(Type type, int index, bool beta, float isoValue, SIGNAL(progressRangeChanged(int, int)), m_progressDialog, SLOT(setRange(int, int))); connect(m_gaussianConcurrent, SIGNAL(finished()), SLOT(displayMesh())); + connect(m_progressDialog, SIGNAL(canceled()), + &m_gaussianConcurrent->watcher(), SLOT(cancel())); } } else { // slaters @@ -643,6 +644,8 @@ void Surfaces::calculateQM(Type type, int index, bool beta, float isoValue, connect(&m_slaterConcurrent->watcher(), SIGNAL(progressRangeChanged(int, int)), m_progressDialog, SLOT(setRange(int, int))); + connect(m_progressDialog, SIGNAL(canceled()), + &m_slaterConcurrent->watcher(), SLOT(cancel())); connect(m_slaterConcurrent, SIGNAL(finished()), SLOT(displayMesh())); } }