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 de38c6111398..8f2e750eb4c5 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 @@ -151,6 +151,9 @@ 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()]) diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/presenter.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/presenter.py index 26858287c2b8..b338c8a71bb7 100644 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/presenter.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/presenter.py @@ -66,13 +66,16 @@ def fit_started(self): def fit_done(self, fit_props): # triggered in the fit property browser self.enable_view() - self.plot_widget.set_final_state_progress_bar(fit_props) - self.plot_widget.fit_completed( - fit_props, - self.data_widget.presenter.get_loaded_ws_list(), - self.data_widget.presenter.get_active_ws_list(), - self.data_widget.presenter.get_log_ws_group_name(), - ) + if fit_props: + self.plot_widget.set_final_state_progress_bar(fit_props) + self.plot_widget.fit_completed( + fit_props, + self.data_widget.presenter.get_loaded_ws_list(), + self.data_widget.presenter.get_active_ws_list(), + self.data_widget.presenter.get_log_ws_group_name(), + ) + else: + self.plot_widget.set_final_state_progress_bar(None, status="Failed, invalid fit.") def disable_view(self, _=None, fit_all=False): self.data_widget.view.setEnabled(False) diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/test/test_presenter.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/test/test_presenter.py index e50c1dc0d092..a2e505a504e8 100644 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/test/test_presenter.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/fitting/test/test_presenter.py @@ -206,6 +206,21 @@ def test_fit_done_call_order(self): [mock.call.enable(), mock.call.progress_bar(fitprop_list), mock.call.fit_completed(fitprop_list, [], [], "")] ) + def test_fit_done_call_order_failed_fit(self): + self.presenter.data_widget.presenter.model.get_all_log_workspaces_names = mock.MagicMock(return_value=[]) + mock_manager = mock.Mock() + self.presenter.enable_view = mock.MagicMock() + self.presenter.plot_widget.set_final_state_progress_bar = mock.MagicMock() + self.presenter.plot_widget.fit_completed = mock.MagicMock() + mock_manager.enable, mock_manager.progress_bar = ( + self.presenter.enable_view, + self.presenter.plot_widget.set_final_state_progress_bar, + ) + + self.presenter.fit_done([]) + mock_manager.assert_has_calls([mock.call.enable(), mock.call.progress_bar(None, status="Failed, invalid fit.")]) + self.presenter.plot_widget.fit_completed.assert_not_called() + def test_enable_view_not_fit_all(self): self.presenter.data_widget.view.setEnabled = mock.MagicMock() self.presenter.plot_widget.enable_view_components = mock.MagicMock() diff --git a/qt/widgets/common/src/FitPropertyBrowser.cpp b/qt/widgets/common/src/FitPropertyBrowser.cpp index bb892a0ec077..65ea65c5bb76 100644 --- a/qt/widgets/common/src/FitPropertyBrowser.cpp +++ b/qt/widgets/common/src/FitPropertyBrowser.cpp @@ -1635,8 +1635,14 @@ void FitPropertyBrowser::doFit(int maxIterations) { } } observeFinish(alg); - alg->executeAsync(); + Poco::ActiveResult result(alg->executeAsync()); m_fitAlgParameters = alg->toString(); + while (!result.available()) { + QCoreApplication::processEvents(); + } + if (!result.error().empty()) { + emit algorithmFinished(QString()); + } } catch (const std::exception &e) { QString msg = "Fit algorithm failed.\n\n" + QString(e.what()) + "\n"; QMessageBox::critical(this, "Mantid - Error", msg);