diff --git a/MantidQt/CustomInterfaces/src/Indirect/ContainerSubtraction.cpp b/MantidQt/CustomInterfaces/src/Indirect/ContainerSubtraction.cpp index be5c0055f87fcb243e8b21ee380ea6e70f4db025..5c32efff5cb97ace5e16e769b5ec0fb6f2636ed8 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ContainerSubtraction.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ContainerSubtraction.cpp @@ -172,9 +172,20 @@ void ContainerSubtraction::addRebinStep(QString toRebin, QString toMatch) { */ bool ContainerSubtraction::validate() { UserInputValidator uiv; + + // Check valid inputs uiv.checkDataSelectorIsValid("Sample", m_uiForm.dsSample); uiv.checkDataSelectorIsValid("Container", m_uiForm.dsContainer); - MatrixWorkspace_sptr sampleWs; + + // Get Workspaces + MatrixWorkspace_sptr sampleWs = + AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( + m_uiForm.dsSample->getCurrentDataName().toStdString()); + MatrixWorkspace_sptr containerWs = + AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( + m_uiForm.dsContainer->getCurrentDataName().toStdString()); + + // Check Sample is of same type as container QString sample = m_uiForm.dsSample->getCurrentDataName(); QString sampleType = sample.right(sample.length() - sample.lastIndexOf("_")); QString container = m_uiForm.dsContainer->getCurrentDataName(); @@ -189,6 +200,15 @@ bool ContainerSubtraction::validate() { uiv.addErrorMessage( "Sample and can workspaces must contain the same type of data."); + // Check sample has the same number of Histograms as the contianer + const size_t sampleHist = sampleWs->getNumberHistograms(); + const size_t containerHist = containerWs->getNumberHistograms(); + + if (sampleHist != containerHist) { + uiv.addErrorMessage( + " Sample and Container do not have a matching number of Histograms."); + } + // Show errors if there are any if (!uiv.isAllInputValid()) emit showMessageBox(uiv.generateErrorMessage());