From 85058bb18c45dda38f8e76be0dc863ecfccdf1d4 Mon Sep 17 00:00:00 2001 From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk> Date: Thu, 19 Jul 2018 17:03:47 +0100 Subject: [PATCH] Don't create table without instrument. Re #23018 --- MantidPlot/src/Mantid/MantidUI.cpp | 6 +++++- .../src/WorkspacePresenter/WorkspaceTreeWidget.cpp | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index a67ed40590c..f6fc450f085 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 9e08a44e462..7e0bb479cb3 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() { -- GitLab