From ae6eee3f3f9615416c00635d611ce32668cf271f Mon Sep 17 00:00:00 2001 From: Elliot Oram <Elliot.Oram@stfc.ac.uk> Date: Fri, 31 Jul 2015 10:56:35 +0100 Subject: [PATCH] Added if statement to halt run if Corrections field is empty Refs #13264 --- .../src/Indirect/ApplyPaalmanPings.cpp | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ApplyPaalmanPings.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ApplyPaalmanPings.cpp index 90dba8e1924..6dcfbd20ac3 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ApplyPaalmanPings.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ApplyPaalmanPings.cpp @@ -336,30 +336,35 @@ bool ApplyPaalmanPings::validate() { } if (useCorrections) { - uiv.checkDataSelectorIsValid("Corrections", m_uiForm.dsCorrections); + if (m_uiForm.dsCorrections->getCurrentDataName().compare("") == 0) { + uiv.addErrorMessage( + "Use Correction must contain a corrections file or workspace."); + } else { - QString correctionsWsName = m_uiForm.dsCorrections->getCurrentDataName(); - WorkspaceGroup_sptr corrections = - AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( - correctionsWsName.toStdString()); - for (size_t i = 0; i < corrections->size(); i++) { - // Check it is a MatrixWorkspace - MatrixWorkspace_sptr factorWs = - boost::dynamic_pointer_cast<MatrixWorkspace>(corrections->getItem(i)); - if (!factorWs) { - QString msg = "Correction factor workspace " + QString::number(i) + - " is not a MatrixWorkspace"; - uiv.addErrorMessage(msg); - continue; - } + QString correctionsWsName = m_uiForm.dsCorrections->getCurrentDataName(); + WorkspaceGroup_sptr corrections = + AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( + correctionsWsName.toStdString()); + for (size_t i = 0; i < corrections->size(); i++) { + // Check it is a MatrixWorkspace + MatrixWorkspace_sptr factorWs = + boost::dynamic_pointer_cast<MatrixWorkspace>( + corrections->getItem(i)); + if (!factorWs) { + QString msg = "Correction factor workspace " + QString::number(i) + + " is not a MatrixWorkspace"; + uiv.addErrorMessage(msg); + continue; + } - // Check X unit is wavelength - Mantid::Kernel::Unit_sptr xUnit = factorWs->getAxis(0)->unit(); - if (xUnit->caption() != "Wavelength") { - QString msg = "Correction factor workspace " + - QString::fromStdString(factorWs->name()) + - " is not in wavelength"; - uiv.addErrorMessage(msg); + // Check X unit is wavelength + Mantid::Kernel::Unit_sptr xUnit = factorWs->getAxis(0)->unit(); + if (xUnit->caption() != "Wavelength") { + QString msg = "Correction factor workspace " + + QString::fromStdString(factorWs->name()) + + " is not in wavelength"; + uiv.addErrorMessage(msg); + } } } } -- GitLab