From 266b9d7de6e217b60489c41389d531f62db5dc48 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:16:23 +0100 Subject: [PATCH 1/2] add algorithmFailed signal/slot --- .../tabs/fitting/plotting/EngDiff_fitpropertybrowser.py | 8 ++++++++ .../inc/MantidQtWidgets/Common/FitPropertyBrowser.h | 1 + qt/widgets/common/src/FitPropertyBrowser.cpp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/EngDiff_fitpropertybrowser.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/EngDiff_fitpropertybrowser.py index 8f2e750eb4c5..379495977b49 100644 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/EngDiff_fitpropertybrowser.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/EngDiff_fitpropertybrowser.py @@ -35,6 +35,7 @@ def __init__(self, canvas, toolbar_manager, parent=None): self.fit_enabled_notifier = GenericObservable() self.fit_started_notifier = GenericObservable() self.algorithmStarted.connect(self.fitting_started_slot) + self.algorithmFailed.connect(self.fitting_failed_slot) def set_output_window_names(self): """ @@ -158,6 +159,13 @@ def fitting_done_slot(self, name): self.save_current_setup(self.workspaceName()) self.fit_notifier.notify_subscribers([self.get_fitprop()]) + @Slot() + def fitting_failed_slot(self): + """ + This is called after Fit fails due to an acception thrown. + """ + self.fit_notifier.notify_subscribers([]) + @Slot() def function_changed_slot(self): """ diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h index c0e6ecb34065..5365acd2e249 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h @@ -333,6 +333,7 @@ public slots: void currentChanged() const; void functionRemoved(); void algorithmFinished(const QString & /*_t1*/); + void algorithmFailed(); void algorithmStarted(const QString & /*_t1*/); void workspaceIndexChanged(int index); void updatePlotSpectrum(int index); diff --git a/qt/widgets/common/src/FitPropertyBrowser.cpp b/qt/widgets/common/src/FitPropertyBrowser.cpp index 65ea65c5bb76..ab43114d62ae 100644 --- a/qt/widgets/common/src/FitPropertyBrowser.cpp +++ b/qt/widgets/common/src/FitPropertyBrowser.cpp @@ -1641,7 +1641,7 @@ void FitPropertyBrowser::doFit(int maxIterations) { QCoreApplication::processEvents(); } if (!result.error().empty()) { - emit algorithmFinished(QString()); + emit algorithmFailed(); } } catch (const std::exception &e) { QString msg = "Fit algorithm failed.\n\n" + QString(e.what()) + "\n"; From 6dd21e234a59b1b8029827860f1a5c399501c51a Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:00:49 +0100 Subject: [PATCH 2/2] remove now redundant code --- .../tabs/fitting/plotting/EngDiff_fitpropertybrowser.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/EngDiff_fitpropertybrowser.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/EngDiff_fitpropertybrowser.py index 379495977b49..2b8e5134f87a 100644 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/EngDiff_fitpropertybrowser.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/EngDiff_fitpropertybrowser.py @@ -152,9 +152,6 @@ def fitting_done_slot(self, name): This is called after Fit finishes to update the fit curves. :param name: The name of Fit's output workspace. """ - if not name: - self.fit_notifier.notify_subscribers([]) - return super(EngDiffFitPropertyBrowser, self).fitting_done_slot(name) self.save_current_setup(self.workspaceName()) self.fit_notifier.notify_subscribers([self.get_fitprop()]) @@ -162,7 +159,7 @@ def fitting_done_slot(self, name): @Slot() def fitting_failed_slot(self): """ - This is called after Fit fails due to an acception thrown. + This is called after Fit fails due to an exception thrown. """ self.fit_notifier.notify_subscribers([])