diff --git a/Framework/API/src/Algorithm.cpp b/Framework/API/src/Algorithm.cpp index e95b083c084a4db9beba993a20643fbb9c1f1d85..860a17a3d66cb681fd368d2f87a4f69347f5af71 100644 --- a/Framework/API/src/Algorithm.cpp +++ b/Framework/API/src/Algorithm.cpp @@ -1278,11 +1278,13 @@ bool Algorithm::processGroups() { // ---------- Create all the output workspaces ---------------------------- for (size_t owp = 0; owp < m_pureOutputWorkspaceProps.size(); owp++) { Property *prop = dynamic_cast<Property *>(m_pureOutputWorkspaceProps[owp]); - WorkspaceGroup_sptr outWSGrp = WorkspaceGroup_sptr(new WorkspaceGroup()); - outGroups.push_back(outWSGrp); - // Put the GROUP in the ADS - AnalysisDataService::Instance().addOrReplace(prop->value(), outWSGrp); - outWSGrp->observeADSNotifications(false); + if (prop) { + WorkspaceGroup_sptr outWSGrp = WorkspaceGroup_sptr(new WorkspaceGroup()); + outGroups.push_back(outWSGrp); + // Put the GROUP in the ADS + AnalysisDataService::Instance().addOrReplace(prop->value(), outWSGrp); + outWSGrp->observeADSNotifications(false); + } } // Go through each entry in the input group(s) diff --git a/Framework/API/src/ExperimentInfo.cpp b/Framework/API/src/ExperimentInfo.cpp index 26a61864f6b9927aad85b761c5e985a894de8ce7..3ddd52bfdf0bbefe09fb0864bbf10fd4f1ba0e93 100644 --- a/Framework/API/src/ExperimentInfo.cpp +++ b/Framework/API/src/ExperimentInfo.cpp @@ -1149,7 +1149,7 @@ void ExperimentInfo::readParameterMap(const std::string ¶meterStr) { // if( comp_name == prev_name ) continue; this blocks reading in different // parameters of the same component. RNT // prev_name = comp_name; - const Geometry::IComponent *comp = 0; + const Geometry::IComponent *comp = NULL; if (comp_name.find("detID:") != std::string::npos) { int detID = atoi(comp_name.substr(6).c_str()); comp = instr->getDetector(detID).get(); @@ -1164,8 +1164,7 @@ void ExperimentInfo::readParameterMap(const std::string ¶meterStr) { continue; } } - if (!comp) - continue; + // create parameter's value as a sum of all tokens with index 3 or larger // this allow a parameter's value to contain ";" std::string paramValue = tokens[3]; diff --git a/Framework/API/src/FunctionFactory.cpp b/Framework/API/src/FunctionFactory.cpp index 5d2a0a1aad401f3cebf7326d1219a3edf99798c1..29a5ec54767c1b593c9cf2e3c028f262707968d6 100644 --- a/Framework/API/src/FunctionFactory.cpp +++ b/Framework/API/src/FunctionFactory.cpp @@ -192,6 +192,9 @@ CompositeFunction_sptr FunctionFactoryImpl::createComposite( inputError(expr.str()); } + if (!cfun) + inputError(expr.str()); + for (; it != terms.end(); ++it) { const Expression &term = it->bracketsRemoved(); IFunction_sptr fun; diff --git a/Framework/API/src/WorkspaceOpOverloads.cpp b/Framework/API/src/WorkspaceOpOverloads.cpp index cfd3595724a9d60b327e5565606e1b504442491d..f29bca1ca5fe27a3bd029a203c5169e2eb8c3897 100644 --- a/Framework/API/src/WorkspaceOpOverloads.cpp +++ b/Framework/API/src/WorkspaceOpOverloads.cpp @@ -5,11 +5,11 @@ #include "MantidAPI/Algorithm.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidKernel/Property.h" -#include "MantidKernel/Exception.h" +//#include "MantidKernel/Exception.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/IWorkspaceProperty.h" #include "MantidAPI/WorkspaceFactory.h" -#include "MantidAPI/SpectraAxis.h" +//#include "MantidAPI/SpectraAxis.h" #include "MantidAPI/IMDWorkspace.h" #include "MantidAPI/IMDHistoWorkspace.h" #include "MantidAPI/WorkspaceGroup_fwd.h" @@ -67,30 +67,20 @@ ResultType executeBinaryOperation(const std::string &algorithmName, alg->execute(); - if (alg->isExecuted()) { - // Get the output workspace property - if (child) { - return alg->getProperty("OutputWorkspace"); - } else { - API::Workspace_sptr result = - API::AnalysisDataService::Instance().retrieve( - alg->getPropertyValue("OutputWorkspace")); - return boost::dynamic_pointer_cast<typename ResultType::element_type>( - result); - } - } else { + if (!alg->isExecuted()) { std::string message = "Error while executing operation: " + algorithmName; throw std::runtime_error(message); } - throw Kernel::Exception::NotFoundError( - "Required output workspace property not found on Child Algorithm", - "OutputWorkspace"); - - // Horendous code inclusion to satisfy compilers that all code paths return a - // value - // in reality the above code should either throw or return successfully. - return ResultType(); + // Get the output workspace property + if (child) { + return alg->getProperty("OutputWorkspace"); + } else { + API::Workspace_sptr result = API::AnalysisDataService::Instance().retrieve( + alg->getPropertyValue("OutputWorkspace")); + return boost::dynamic_pointer_cast<typename ResultType::element_type>( + result); + } } template DLLExport MatrixWorkspace_sptr @@ -169,14 +159,12 @@ bool equals(const MatrixWorkspace_sptr lhs, const MatrixWorkspace_sptr rhs, // Rest: use default alg->execute(); - if (alg->isExecuted()) { - return (alg->getPropertyValue("Result") == "Success!"); - } else { + if (!alg->isExecuted()) { std::string message = "Error while executing operation: CheckWorkspacesMatch"; throw std::runtime_error(message); } - return false; + return (alg->getPropertyValue("Result") == "Success!"); } /** Creates a temporary single value workspace the error is set to zero @@ -512,17 +500,18 @@ bool WorkspaceHelpers::matchingBins(const MatrixWorkspace_const_sptr ws1, if (!step) step = 1; for (size_t i = step; i < numHist; i += step) { - const double firstWS = + const double firstWSLoop = std::accumulate(ws1->readX(i).begin(), ws1->readX(i).end(), 0.); - const double secondWS = + const double secondWSLoop = std::accumulate(ws2->readX(i).begin(), ws2->readX(i).end(), 0.); - if (std::abs(firstWS) < 1.0E-7 && std::abs(secondWS) < 1.0E-7) { + if (std::abs(firstWSLoop) < 1.0E-7 && std::abs(secondWSLoop) < 1.0E-7) { for (size_t j = 0; j < ws1->readX(i).size(); j++) { if (std::abs(ws1->readX(i)[j] - ws2->readX(i)[j]) > 1.0E-7) return false; } - } else if (std::abs(firstWS - secondWS) / - std::max<double>(std::abs(firstWS), std::abs(secondWS)) > + } else if (std::abs(firstWSLoop - secondWSLoop) / + std::max<double>(std::abs(firstWSLoop), + std::abs(secondWSLoop)) > 1.0E-7) return false; } diff --git a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp index a6e0cb33adfc00ecba56d322c2c4855662b143b7..8a499988135764aab495cdd5a00cc597532619eb 100644 --- a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp +++ b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp @@ -168,6 +168,11 @@ void CorelliCrossCorrelate::exec() { // Determine period from chopper frequency. auto motorSpeed = dynamic_cast<TimeSeriesProperty<double> *>( inputWS->run().getProperty("BL9:Chop:Skf4:MotorSpeed")); + if (!motorSpeed) { + throw Exception::NotFoundError( + "Could not find a log value for the motor speed", + "BL9:Chop:Skf4:MotorSpeed"); + } double period = 1e9 / static_cast<double>(motorSpeed->timeAverageValue()); g_log.information() << "Frequency = " << 1e9 / period << "Hz Period = " << period << "ns\n"; diff --git a/Framework/Crystal/src/FilterPeaks.cpp b/Framework/Crystal/src/FilterPeaks.cpp index 8e398c2b0de67a54cfba1205285caa2be5a0808c..f60acecea9586ca7449801c11b174ecdbefd7e16 100644 --- a/Framework/Crystal/src/FilterPeaks.cpp +++ b/Framework/Crystal/src/FilterPeaks.cpp @@ -98,6 +98,8 @@ void FilterPeaks::exec() { filterFunction = &intensity; else if (FilterVariable == "Signal/Noise") filterFunction = &SN; + else + throw std::invalid_argument("Unknown FilterVariable: " + FilterVariable); const double FilterValue = getProperty("FilterValue"); const std::string Operator = getProperty("Operator"); diff --git a/Framework/Crystal/src/LoadIsawSpectrum.cpp b/Framework/Crystal/src/LoadIsawSpectrum.cpp index 1020210a59d8f48c1c261685b9a4e787d7427f38..20e26e01cda8e944690d35d46093fef418e917bf 100644 --- a/Framework/Crystal/src/LoadIsawSpectrum.cpp +++ b/Framework/Crystal/src/LoadIsawSpectrum.cpp @@ -69,38 +69,24 @@ void LoadIsawSpectrum::exec() { std::vector<std::vector<double>> spectra; std::vector<std::vector<double>> time; int iSpec = 0; - if (iSpec == 1) { - while (!infile.eof()) // To get you all the lines. - { - // Set up sizes. (HEIGHT x WIDTH) - spectra.resize(a + 1); - getline(infile, STRING); // Saves the line in STRING. - infile >> spec[0] >> spec[1] >> spec[2] >> spec[3] >> spec[4] >> - spec[5] >> spec[6] >> spec[7] >> spec[8] >> spec[9] >> spec[10]; - for (int i = 0; i < 11; i++) - spectra[a].push_back(spec[i]); - a++; - } - } else { - for (int wi = 0; wi < 8; wi++) - getline(infile, STRING); // Saves the line in STRING. - while (!infile.eof()) // To get you all the lines. - { - time.resize(a + 1); - spectra.resize(a + 1); - getline(infile, STRING); // Saves the line in STRING. - if (infile.eof()) - break; - std::stringstream ss(STRING); - if (STRING.find("Bank") == std::string::npos) { - double time0, spectra0; - ss >> time0 >> spectra0; - time[a].push_back(time0); - spectra[a].push_back(spectra0); + for (int wi = 0; wi < 8; wi++) + getline(infile, STRING); // Saves the line in STRING. + while (!infile.eof()) // To get you all the lines. + { + time.resize(a + 1); + spectra.resize(a + 1); + getline(infile, STRING); // Saves the line in STRING. + if (infile.eof()) + break; + std::stringstream ss(STRING); + if (STRING.find("Bank") == std::string::npos) { + double time0, spectra0; + ss >> time0 >> spectra0; + time[a].push_back(time0); + spectra[a].push_back(spectra0); - } else { - a++; - } + } else { + a++; } } infile.close(); diff --git a/Framework/Crystal/src/SaveHKL.cpp b/Framework/Crystal/src/SaveHKL.cpp index 531893ebf5181eaacb538ee2eb25602000c59645..3129a148080f65782324bc85faa06dc5f2a05247 100644 --- a/Framework/Crystal/src/SaveHKL.cpp +++ b/Framework/Crystal/src/SaveHKL.cpp @@ -230,37 +230,23 @@ void SaveHKL::exec() { infile.open(spectraFile.c_str()); if (infile.is_open()) { size_t a = 0; - if (iSpec == 1) { - while (!infile.eof()) // To get you all the lines. - { - // Set up sizes. (HEIGHT x WIDTH) - spectra.resize(a + 1); - getline(infile, STRING); // Saves the line in STRING. - infile >> spec[0] >> spec[1] >> spec[2] >> spec[3] >> spec[4] >> - spec[5] >> spec[6] >> spec[7] >> spec[8] >> spec[9] >> spec[10]; - for (int i = 0; i < 11; i++) - spectra[a].push_back(spec[i]); + for (int wi = 0; wi < 8; wi++) + getline(infile, STRING); // Saves the line in STRING. + while (!infile.eof()) // To get you all the lines. + { + time.resize(a + 1); + spectra.resize(a + 1); + getline(infile, STRING); // Saves the line in STRING. + std::stringstream ss(STRING); + if (STRING.find("Bank") == std::string::npos) { + double time0, spectra0; + ss >> time0 >> spectra0; + time[a].push_back(time0); + spectra[a].push_back(spectra0); + + } else { a++; } - } else { - for (int wi = 0; wi < 8; wi++) - getline(infile, STRING); // Saves the line in STRING. - while (!infile.eof()) // To get you all the lines. - { - time.resize(a + 1); - spectra.resize(a + 1); - getline(infile, STRING); // Saves the line in STRING. - std::stringstream ss(STRING); - if (STRING.find("Bank") == std::string::npos) { - double time0, spectra0; - ss >> time0 >> spectra0; - time[a].push_back(time0); - spectra[a].push_back(spectra0); - - } else { - a++; - } - } } infile.close(); } diff --git a/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp b/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp index b69b92fdba2ae6bc11c07eaadbd5e5c46d75924d..87801460543315e7aaccd4501e43e74facf27e8f 100644 --- a/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp +++ b/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp @@ -2021,7 +2021,6 @@ bool FitPowderDiffPeaks::doFitMultiplePeaks( // 1. Fit peaks intensities first const size_t numpeaks = peakfuncs.size(); map<string, double> peaksfuncparams; - bool evergood = true; // a) Set up fit/fix vector<string> peakparnames = peakfuncs[0]->getParameterNames(); @@ -2045,7 +2044,7 @@ bool FitPowderDiffPeaks::doFitMultiplePeaks( double chi2; bool fitgood = doFitNPeaksSimple(dataws, wsindex, peaksfunc, peakfuncs, "Levenberg-MarquardtMD", 1000, chi2); - evergood = evergood || fitgood; + bool evergood = fitgood; // c) Process result if (!fitgood) { diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp index 60e3d731b21978a1bb9b3ed92ab4deb36575ab06..21d6e9af3d6c32ae3b6a07aa2cd14487ad0aac60 100644 --- a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp +++ b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp @@ -341,7 +341,7 @@ void LeBailFit::exec() { case FIT: // LeBail Fit g_log.notice() << "Function: Do LeBail Fit ==> Monte Carlo.\n"; - + // fall through case MONTECARLO: // Monte carlo Le Bail refinement g_log.notice("Function: Do LeBail Fit By Monte Carlo Random Walk."); diff --git a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp index 93b2e86016a7320e17d3ae657789ec49ad86da6f..a19fa51061060d39206dd760f8a1d8db453d9fb0 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp @@ -66,8 +66,7 @@ void SplineBackground::exec() { bool isMasked = inWS->hasMaskedBins(spec); std::vector<int> masked(Y.size()); if (isMasked) { - for (API::MatrixWorkspace::MaskList::const_iterator it = - inWS->maskedBins(spec).begin(); + for (auto it = inWS->maskedBins(spec).begin(); it != inWS->maskedBins(spec).end(); ++it) masked[it->first] = 1; n -= static_cast<int>(inWS->maskedBins(spec).size()); diff --git a/Framework/DataHandling/src/GroupDetectors2.cpp b/Framework/DataHandling/src/GroupDetectors2.cpp index 060f54bee77e172c5cfa3da87e6294c5f0aea2c2..4bfba12fc4a42003b33a2c65d620b6507a154fe0 100644 --- a/Framework/DataHandling/src/GroupDetectors2.cpp +++ b/Framework/DataHandling/src/GroupDetectors2.cpp @@ -353,7 +353,7 @@ void GroupDetectors2::getGroups(API::MatrixWorkspace_const_sptr workspace, } // check we don't have an index that is too high for the workspace size_t maxIn = static_cast<size_t>(workspace->getNumberHistograms() - 1); - std::vector<size_t>::const_iterator it = m_GroupSpecInds[0].begin(); + auto it = m_GroupSpecInds[0].begin(); for (; it != m_GroupSpecInds[0].end(); ++it) { if (*it > maxIn) { g_log.error() << "Spectra index " << *it @@ -375,7 +375,7 @@ void GroupDetectors2::getGroups(API::MatrixWorkspace_const_sptr workspace, // up date unUsedSpec, this is used to find duplicates and when the user has // set KeepUngroupedSpectra - std::vector<size_t>::const_iterator index = m_GroupSpecInds[0].begin(); + auto index = m_GroupSpecInds[0].begin(); for (; index != m_GroupSpecInds[0].end(); ++index) { // the vector<int> m_GroupSpecInds[0] must not index contain // numbers that don't exist in the workspaace diff --git a/Framework/DataObjects/src/EventList.cpp b/Framework/DataObjects/src/EventList.cpp index efb6e74c71354d9c2d6207883c39d49a6e1e95f2..8dfbd6d9421904169c2016b3f5f11279c626469a 100644 --- a/Framework/DataObjects/src/EventList.cpp +++ b/Framework/DataObjects/src/EventList.cpp @@ -548,6 +548,7 @@ EventList &EventList::operator-=(const EventList &more_events) { minusHelper(this->weightedEvents, more_events.weightedEventsNoTime); break; } + break; case WEIGHTED_NOTIME: switch (more_events.getEventType()) { @@ -561,6 +562,7 @@ EventList &EventList::operator-=(const EventList &more_events) { minusHelper(this->weightedEventsNoTime, more_events.weightedEventsNoTime); break; } + break; } // No guaranteed order diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index 7451386f8b8db60e5b313c9fbb60b6623ff0cae6..f4c9afef815111745fea386715ae9a79b4d531ea 100644 --- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -2309,7 +2309,9 @@ void InstrumentDefinitionParser::createNeutronicInstrument() { mapTypeNameToShape.find(shapeName); if (shapeIt != mapTypeNameToShape.end()) { // Change the shape on the current component to the one requested - dynamic_cast<ObjComponent *>(it->first)->setShape(shapeIt->second); + auto objCmpt = dynamic_cast<ObjComponent *>(it->first); + if (objCmpt) + objCmpt->setShape(shapeIt->second); } else { throw Exception::InstrumentDefinitionError( "Requested type " + shapeName + " not defined in IDF"); diff --git a/Framework/Kernel/src/Matrix.cpp b/Framework/Kernel/src/Matrix.cpp index f4e1adc13197297776e06c33da66c50614498298..014284f04c4da6b769c33f2d1157cb0390e3f336 100644 --- a/Framework/Kernel/src/Matrix.cpp +++ b/Framework/Kernel/src/Matrix.cpp @@ -158,17 +158,20 @@ Matrix<T>::Matrix(const Matrix<T> &A, const size_t nrow, const size_t ncol) throw Kernel::Exception::IndexError(ncol, A.ny, "Matrix::Constructor without col"); setMem(nx, ny); - size_t iR(0); - for (size_t i = 0; i <= nx; i++) { - if (i != nrow) { - size_t jR(0); - for (size_t j = 0; j <= ny; j++) { - if (j != ncol) { - V[iR][jR] = A.V[i][j]; - jR++; + if (V) { + size_t iR(0); + for (size_t i = 0; i <= nx; i++) { + if (i != nrow) { + size_t jR(0); + for (size_t j = 0; j <= ny; j++) { + if (j != ncol) { + + V[iR][jR] = A.V[i][j]; + jR++; + } } + iR++; } - iR++; } } } diff --git a/Framework/MDAlgorithms/src/FindPeaksMD.cpp b/Framework/MDAlgorithms/src/FindPeaksMD.cpp index 1e94707a155f447cab458f8d4b2e3528fef25294..ba70dd4bedd2239fcf40c699cdac43d92045abe3 100644 --- a/Framework/MDAlgorithms/src/FindPeaksMD.cpp +++ b/Framework/MDAlgorithms/src/FindPeaksMD.cpp @@ -215,12 +215,15 @@ FindPeaksMD::createPeak(const Mantid::Kernel::V3D &Q, const double binCount) { boost::shared_ptr<DataObjects::Peak> p; if (dimType == QLAB) { // Build using the Q-lab-frame constructor - p = boost::shared_ptr<DataObjects::Peak>(new Peak(inst, Q)); + p = boost::make_shared<Peak>(inst, Q); // Save gonio matrix for later p->setGoniometerMatrix(m_goniometer); } else if (dimType == QSAMPLE) { // Build using the Q-sample-frame constructor - p = boost::shared_ptr<DataObjects::Peak>(new Peak(inst, Q, m_goniometer)); + p = boost::make_shared<Peak>(inst, Q, m_goniometer); + } else { + throw std::invalid_argument( + "Cannot Integrate peaks unless the dimension is QLAB or QSAMPLE"); } try { // Look for a detector diff --git a/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp b/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp index 711de48f4bf03d29ae298d0aaebf6c47f0f01693..1468a6001c3194cd40433439827f19207efa27ae 100644 --- a/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp +++ b/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp @@ -386,6 +386,10 @@ void IntegrateMDHistoWorkspace::exec() { // Create a thread-local input iterator. boost::scoped_ptr<MDHistoWorkspaceIterator> inIterator( dynamic_cast<MDHistoWorkspaceIterator *>(inWS->createIterator())); + if (!inIterator) { + throw std::runtime_error( + "Could not convert IMDIterator to a MDHistoWorkspaceIterator"); + } /* We jump to the iterator position which is closest in the model diff --git a/Framework/WorkflowAlgorithms/src/RefReduction.cpp b/Framework/WorkflowAlgorithms/src/RefReduction.cpp index 4ece40c1ee5a6b08b584bceb6cc4eb34b8aee91b..c65be0ce528d4931c1d315a5a70e4ce20c321a22 100644 --- a/Framework/WorkflowAlgorithms/src/RefReduction.cpp +++ b/Framework/WorkflowAlgorithms/src/RefReduction.cpp @@ -629,6 +629,8 @@ double RefReduction::calculateAngleREFM(MatrixWorkspace_sptr workspace) { Mantid::Kernel::Property *prop = workspace->run().getProperty("SampleDetDis"); Mantid::Kernel::TimeSeriesProperty<double> *dp = dynamic_cast<Mantid::Kernel::TimeSeriesProperty<double> *>(prop); + if (!dp) + throw std::runtime_error("SampleDetDis was not a TimeSeriesProperty"); const double det_distance = dp->getStatistics().mean / 1000.0; double direct_beam_pix = getProperty("DirectPixel"); diff --git a/MantidPlot/src/ConfigDialog.cpp b/MantidPlot/src/ConfigDialog.cpp index 6344d67d31cb6107058a72196d4b9b7feec1ac5a..87e74e4ea83cab6eb72537345019aeadb92dc4f3 100644 --- a/MantidPlot/src/ConfigDialog.cpp +++ b/MantidPlot/src/ConfigDialog.cpp @@ -2341,8 +2341,11 @@ void ConfigDialog::apply() QList<MdiSubWindow*> windows = app->windowsList(); foreach(MdiSubWindow *w, windows){ if (w->isA("MultiLayer")){ - (dynamic_cast<MultiLayer*>(w))->setScaleLayersOnPrint(boxScaleLayersOnPrint->isChecked()); - (dynamic_cast<MultiLayer*>(w))->printCropmarks(boxPrintCropmarks->isChecked()); + MultiLayer* multiLayer = dynamic_cast<MultiLayer*>(w); + if (multiLayer) { + multiLayer->setScaleLayersOnPrint(boxScaleLayersOnPrint->isChecked()); + multiLayer->printCropmarks(boxPrintCropmarks->isChecked()); + } } } // general page: application tab diff --git a/MantidPlot/src/ContourLinesEditor.cpp b/MantidPlot/src/ContourLinesEditor.cpp index 19ff48b3bf2c9a39d2da9d592d99f953a1315e9b..144b2c7f245cd9c0bbb736cbee787ba77a733413 100644 --- a/MantidPlot/src/ContourLinesEditor.cpp +++ b/MantidPlot/src/ContourLinesEditor.cpp @@ -108,10 +108,14 @@ void ContourLinesEditor::updateContourLevels() int rows = table->rowCount(); QwtValueList levels; - for (int i = 0; i < rows; i++) - levels << dynamic_cast<DoubleSpinBox*>(table->cellWidget(i, 0))->value(); + for (int i = 0; i < rows; i++) { + DoubleSpinBox *spinBox = + dynamic_cast<DoubleSpinBox *>(table->cellWidget(i, 0)); + if (spinBox) + levels << spinBox->value(); + } - d_spectrogram->setContourLevels(levels); + d_spectrogram->setContourLevels(levels); } void ContourLinesEditor::updateContourPens() diff --git a/MantidPlot/src/CustomActionDialog.cpp b/MantidPlot/src/CustomActionDialog.cpp index 0ffe792247682d974fbf3c6af8338c200fa32c61..8b779deb8ec2a2fb4978b0b5a1439b5d8ba7b504 100644 --- a/MantidPlot/src/CustomActionDialog.cpp +++ b/MantidPlot/src/CustomActionDialog.cpp @@ -514,7 +514,10 @@ void CustomActionDialog::chooseFolder() QAction * CustomActionDialog::actionAt(int row) { ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(parent()); - QList<QAction *>actions = app->customActionsList(); + if (!app) + throw std::runtime_error( + "The parent of this dialog was not the Application Window"); + QList<QAction *>actions = app->customActionsList(); if (actions.isEmpty() || row < 0 || row >= actions.count()) return 0; diff --git a/MantidPlot/src/Mantid/InstrumentWidget/UnwrappedSurface.cpp b/MantidPlot/src/Mantid/InstrumentWidget/UnwrappedSurface.cpp index d83662b41b3b486ee0e4da6bce7f7fb13c2a5f1c..77766f8eff2801fa872fa1d9c612ba5122370e61 100644 --- a/MantidPlot/src/Mantid/InstrumentWidget/UnwrappedSurface.cpp +++ b/MantidPlot/src/Mantid/InstrumentWidget/UnwrappedSurface.cpp @@ -581,8 +581,8 @@ void UnwrappedSurface::drawSimpleToImage(QImage* image,bool picking)const if ( iw < 4 ) iw = 4; if ( ih < 4 ) ih = 4; - double w = (iw == 0)? dw : udet.width/2; - double h = (ih == 0)? dh : udet.height/2; + double w = udet.width/2; + double h = udet.height/2; if (!(m_viewRect.contains(udet.u-w, udet.v-h) || m_viewRect.contains(udet.u+w, udet.v+h))) continue; diff --git a/MantidPlot/src/ScaleDetails.cpp b/MantidPlot/src/ScaleDetails.cpp index 71190376094ff0093f8972b303d2eba67214edcd..e6ef88b10316eb1eaf83abc126038653d8a710d5 100644 --- a/MantidPlot/src/ScaleDetails.cpp +++ b/MantidPlot/src/ScaleDetails.cpp @@ -272,6 +272,10 @@ void ScaleDetails::initWidgets() if (type == ScaleDraw::Date) { ScaleDraw *sclDraw = dynamic_cast<ScaleDraw *>(d_plot->axisScaleDraw(m_mappedaxis)); + if (!sclDraw) { + throw std::runtime_error("Could not convert the axis Scale Draw object " + "to a ScaleDraw object"); + } QDateTime origin = sclDraw->dateTimeOrigin(); m_dspnStart->hide(); diff --git a/MantidQt/CustomInterfaces/src/Indirect/ApplyPaalmanPings.cpp b/MantidQt/CustomInterfaces/src/Indirect/ApplyPaalmanPings.cpp index 31673e9553664f2238fd0c76a269b296e74d3688..e4e9d4484706608f74596258ca4846cf1bc906b7 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ApplyPaalmanPings.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ApplyPaalmanPings.cpp @@ -145,6 +145,7 @@ void ApplyPaalmanPings::run() { switch (result) { case QMessageBox::YesToAll: interpolateAll = true; + //fall through case QMessageBox::Yes: addInterpolationStep(factorWs, absCorProps["SampleWorkspace"]); break; diff --git a/MantidQt/CustomInterfaces/src/Tomography/TomographyIfaceModel.cpp b/MantidQt/CustomInterfaces/src/Tomography/TomographyIfaceModel.cpp index 15c9f4550e6d57228cd464e6c3cb350e47c23449..5aaaaccde66a10647182a685e42fefe0ca5570aa 100644 --- a/MantidQt/CustomInterfaces/src/Tomography/TomographyIfaceModel.cpp +++ b/MantidQt/CustomInterfaces/src/Tomography/TomographyIfaceModel.cpp @@ -582,7 +582,6 @@ TomographyIfaceModel::loadFITSImage(const std::string &path) { "Failed to load image. Could not load this file as a " "FITS image: " + std::string(e.what())); - return WorkspaceGroup_sptr(); } if (!alg->isExecuted()) { throw std::runtime_error( diff --git a/Vates/VatesAPI/src/vtkMDHistoQuadFactory.cpp b/Vates/VatesAPI/src/vtkMDHistoQuadFactory.cpp index 748722813c5ac3a15ecafcdd812c525e03cee2c2..5413e173b246519bac7a43cb2f923107b971d8ea 100644 --- a/Vates/VatesAPI/src/vtkMDHistoQuadFactory.cpp +++ b/Vates/VatesAPI/src/vtkMDHistoQuadFactory.cpp @@ -92,6 +92,12 @@ namespace Mantid coord_t incrementX = (maxX - minX) / static_cast<coord_t>(nBinsX); coord_t incrementY = (maxY - minY) / static_cast<coord_t>(nBinsY); + boost::scoped_ptr<MDHistoWorkspaceIterator> iterator(dynamic_cast<MDHistoWorkspaceIterator*>(createIteratorWithNormalization(m_normalizationOption, m_workspace.get()))); + if (!iterator) { + throw std::runtime_error( + "Could not convert IMDIterator to a MDHistoWorkspaceIterator"); + } + const int imageSize = (nBinsX ) * (nBinsY ); vtkPoints *points = vtkPoints::New(); points->Allocate(static_cast<int>(imageSize)); @@ -119,8 +125,7 @@ namespace Mantid double progressFactor = 0.5/double(nBinsX); double progressOffset = 0.5; - boost::scoped_ptr<MDHistoWorkspaceIterator> iterator(dynamic_cast<MDHistoWorkspaceIterator*>(createIteratorWithNormalization(m_normalizationOption, m_workspace.get()))); - + size_t index = 0; for (int i = 0; i < nBinsX; i++) {