Skip to content

Commit

Permalink
Merge pull request #36269 from mantidproject/36265_handle_errors_in_f…
Browse files Browse the repository at this point in the history
…itting

Reenable error handling in FitPropertyBrowser
  • Loading branch information
thomashampson authored Oct 10, 2023
2 parents 6ed7167 + 6dd21e2 commit b75cfaa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -151,13 +152,17 @@ 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()])

@Slot()
def fitting_failed_slot(self):
"""
This is called after Fit fails due to an exception thrown.
"""
self.fit_notifier.notify_subscribers([])

@Slot()
def function_changed_slot(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion qt/widgets/common/src/FitPropertyBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit b75cfaa

Please sign in to comment.