Skip to content
Snippets Groups Projects
Commit 467931de authored by Rob Applin's avatar Rob Applin
Browse files

refs #22524 Catch unexpected errors

parent 82f81cb6
No related merge requests found
...@@ -808,6 +808,11 @@ FitPropertyBrowser::tryCreateFitFunction(const QString &str) { ...@@ -808,6 +808,11 @@ FitPropertyBrowser::tryCreateFitFunction(const QString &str) {
"A workspace provided in the function does not exist:\n" + "A workspace provided in the function does not exist:\n" +
QString(ex.what())); QString(ex.what()));
return nullptr; return nullptr;
} catch (const std::exception &ex) {
QMessageBox::critical(this, "Mantid - Error",
"Unexpected exception caught\n\n" +
QString(ex.what()));
return nullptr;
} }
} }
...@@ -1099,8 +1104,8 @@ std::string FitPropertyBrowser::workspaceName() const { ...@@ -1099,8 +1104,8 @@ std::string FitPropertyBrowser::workspaceName() const {
void FitPropertyBrowser::setWorkspaceName(const QString &wsName) { void FitPropertyBrowser::setWorkspaceName(const QString &wsName) {
int i = m_workspaceNames.indexOf(wsName); int i = m_workspaceNames.indexOf(wsName);
if (i < 0) { if (i < 0) {
// workspace may not be found because add notification hasn't been processed // workspace may not be found because add notification hasn't been
// yet // processed yet
populateWorkspaceNames(); populateWorkspaceNames();
i = m_workspaceNames.indexOf(wsName); i = m_workspaceNames.indexOf(wsName);
} }
...@@ -1458,8 +1463,8 @@ void FitPropertyBrowser::stringChanged(QtProperty *prop) { ...@@ -1458,8 +1463,8 @@ void FitPropertyBrowser::stringChanged(QtProperty *prop) {
<< parName.toLatin1().constData() << "\n"; << parName.toLatin1().constData() << "\n";
} }
delete tie; delete tie;
} else if (getHandler()->setAttribute( } else if (getHandler()->setAttribute(prop)) { // setting an attribute may
prop)) { // setting an attribute may change function parameters // change function parameters
emit functionChanged(); emit functionChanged();
return; return;
} }
...@@ -1719,9 +1724,9 @@ void FitPropertyBrowser::populateWorkspaceNames() { ...@@ -1719,9 +1724,9 @@ void FitPropertyBrowser::populateWorkspaceNames() {
*/ */
void FitPropertyBrowser::showEvent(QShowEvent *e) { void FitPropertyBrowser::showEvent(QShowEvent *e) {
(void)e; (void)e;
// Observe what workspaces are added and deleted unless it's a custom fitting, // Observe what workspaces are added and deleted unless it's a custom
// all workspaces for custom fitting (eg muon analysis) // fitting, all workspaces for custom fitting (eg muon analysis) should be
// should be manually added. // manually added.
setADSObserveEnabled(true); setADSObserveEnabled(true);
populateWorkspaceNames(); populateWorkspaceNames();
} }
...@@ -2124,9 +2129,8 @@ void FitPropertyBrowser::deleteTie() { ...@@ -2124,9 +2129,8 @@ void FitPropertyBrowser::deleteTie() {
if (function->parameterName( if (function->parameterName(
static_cast<int>(parameterRef.getLocalIndex())) == parName) { static_cast<int>(parameterRef.getLocalIndex())) == parName) {
if (ithParameter == -1 && if (ithParameter == -1 &&
function == function == h->function().get()) // If this is the 'tied from'
h->function() // parameter, remember it
.get()) // If this is the 'tied from' parameter, remember it
{ {
ithParameter = static_cast<int>(i); ithParameter = static_cast<int>(i);
} else // Otherwise add it to the list of potential 'tyees' } else // Otherwise add it to the list of potential 'tyees'
...@@ -2251,14 +2255,14 @@ void FitPropertyBrowser::addUpperBound50() { addConstraint(50, false, true); } ...@@ -2251,14 +2255,14 @@ void FitPropertyBrowser::addUpperBound50() { addConstraint(50, false, true); }
void FitPropertyBrowser::addUpperBound() { addConstraint(0, false, true); } void FitPropertyBrowser::addUpperBound() { addConstraint(0, false, true); }
/** /**
* Slot.Sets the lower and upper bounds of the selected parameter to 10% of its * Slot.Sets the lower and upper bounds of the selected parameter to 10% of
* value * its value
*/ */
void FitPropertyBrowser::addBothBounds10() { addConstraint(10, true, true); } void FitPropertyBrowser::addBothBounds10() { addConstraint(10, true, true); }
/** /**
* Slot.Sets the lower and upper bounds of the selected parameter to 50% of its * Slot.Sets the lower and upper bounds of the selected parameter to 50% of
* value * its value
*/ */
void FitPropertyBrowser::addBothBounds50() { addConstraint(50, true, true); } void FitPropertyBrowser::addBothBounds50() { addConstraint(50, true, true); }
...@@ -2291,7 +2295,8 @@ void FitPropertyBrowser::plotGuessCurrent() { emit plotCurrentGuess(); } ...@@ -2291,7 +2295,8 @@ void FitPropertyBrowser::plotGuessCurrent() { emit plotCurrentGuess(); }
void FitPropertyBrowser::plotGuessAll() { emit plotGuess(); } void FitPropertyBrowser::plotGuessAll() { emit plotGuess(); }
/** /**
* Slot. Sends a signal to remove the guess for the current (selected) function * Slot. Sends a signal to remove the guess for the current (selected)
* function
*/ */
void FitPropertyBrowser::removeGuessCurrent() { emit removeCurrentGuess(); } void FitPropertyBrowser::removeGuessCurrent() { emit removeCurrentGuess(); }
...@@ -2791,8 +2796,8 @@ void FitPropertyBrowser::setupMultifit() { ...@@ -2791,8 +2796,8 @@ void FitPropertyBrowser::setupMultifit() {
} }
} }
QString wsParam = ",WSParam=(WorkspaceIndex=" + QString::number(i); QString wsParam = ",WSParam=(WorkspaceIndex=" + QString::number(i);
wsParam += ",StartX=" + QString::number(startX()) + ",EndX=" + wsParam += ",StartX=" + QString::number(startX()) +
QString::number(endX()) + ")"; ",EndX=" + QString::number(endX()) + ")";
funIni += fun1Ini + ",Workspace=" + wsName + wsParam + ";"; funIni += fun1Ini + ",Workspace=" + wsName + wsParam + ";";
} }
if (!tieStr.isEmpty()) { if (!tieStr.isEmpty()) {
...@@ -2998,9 +3003,9 @@ void FitPropertyBrowser::addWorkspaceIndexToBrowser() { ...@@ -2998,9 +3003,9 @@ void FitPropertyBrowser::addWorkspaceIndexToBrowser() {
} }
/**================================================================================================= /**=================================================================================================
* Create a MatrixWorkspace from a TableWorkspace. Name of the TableWorkspace is * Create a MatrixWorkspace from a TableWorkspace. Name of the TableWorkspace
* in m_workspace * is in m_workspace property, column names to use are in m_xColumn,
* property, column names to use are in m_xColumn, m_yColumn, and m_errColumn. * m_yColumn, and m_errColumn.
*/ */
Mantid::API::Workspace_sptr Mantid::API::Workspace_sptr
FitPropertyBrowser::createMatrixFromTableWorkspace() const { FitPropertyBrowser::createMatrixFromTableWorkspace() const {
...@@ -3078,8 +3083,8 @@ void FitPropertyBrowser::fit() { ...@@ -3078,8 +3083,8 @@ void FitPropertyBrowser::fit() {
} }
/**================================================================================================= /**=================================================================================================
* Slot connected to the change signals of properties m_xColumn, m_yColumn, and * Slot connected to the change signals of properties m_xColumn, m_yColumn,
* m_errColumn. * and m_errColumn.
* @param prop :: Property that changed. * @param prop :: Property that changed.
*/ */
void FitPropertyBrowser::columnChanged(QtProperty *prop) { void FitPropertyBrowser::columnChanged(QtProperty *prop) {
...@@ -3221,7 +3226,8 @@ void FitPropertyBrowser::browserHelp() { ...@@ -3221,7 +3226,8 @@ void FitPropertyBrowser::browserHelp() {
} }
/**================================================================================================= /**=================================================================================================
* Allow/disallow sequential fits, depending on whether other conditions are met * Allow/disallow sequential fits, depending on whether other conditions are
* met
* @param allow :: [input] Allow or disallow * @param allow :: [input] Allow or disallow
*/ */
void FitPropertyBrowser::allowSequentialFits(bool allow) { void FitPropertyBrowser::allowSequentialFits(bool allow) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment