diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index a67ed40590ca12365844b06f30f9ab1317ab21da..f6fc450f085c72a4f4579bf2b31fcc5f8889c710 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -1270,6 +1270,11 @@ Table *MantidUI::createDetectorTable( const std::vector<int> &indices, bool include_data) { using namespace Mantid::Geometry; + IComponent_const_sptr sample = ws->getInstrument()->getSample(); + if (!sample) { + return nullptr; + } + // check if efixed value is available bool calcQ(true); @@ -1330,7 +1335,6 @@ Table *MantidUI::createDetectorTable( t->setTextFormat(ncols - 1); // Cache some frequently used values - IComponent_const_sptr sample = ws->getInstrument()->getSample(); const auto beamAxisIndex = ws->getInstrument()->getReferenceFrame()->pointingAlongBeam(); const auto sampleDist = sample->getPos()[beamAxisIndex]; diff --git a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp index 9e08a44e462f97b068dab68b1b3c437ea8753aa5..7e0bb479cb329f963ec5adc936053b5c0030fa9d 100644 --- a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp +++ b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp @@ -1600,9 +1600,14 @@ void WorkspaceTreeWidget::onClickShowDetectorTable() { void WorkspaceTreeWidget::showDetectorsTable() { // get selected workspace - auto ws = getSelectedWorkspaceNames()[0]; - m_mantidDisplayModel->createDetectorTable(QString::fromStdString(ws), - std::vector<int>(), false); + auto ws = QString::fromStdString(getSelectedWorkspaceNames()[0]); + auto table = + m_mantidDisplayModel->createDetectorTable(ws, std::vector<int>(), false); + if (!table) { + QMessageBox::information( + this, "Error", + QString("Cannot create detectors tables for workspace ") + ws); + } } void WorkspaceTreeWidget::onClickShowBoxData() {