diff --git a/qt/widgets/instrumentview/src/InstrumentWidget.cpp b/qt/widgets/instrumentview/src/InstrumentWidget.cpp index ce2567b09b38c6c2bef0c95a0884346692c34302..59e61ed9584ec5af64e5c0a76d14c93dded8b99a 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidget.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidget.cpp @@ -8,6 +8,7 @@ #include "MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h" #include "MantidQtWidgets/InstrumentView/InstrumentWidgetTreeTab.h" #include "MantidGeometry/Instrument/ComponentInfo.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidAPI/Axis.h" #include "MantidAPI/IMaskWorkspace.h" @@ -1234,24 +1235,17 @@ void InstrumentWidget::handleWorkspaceReplacement( close(); return; } - bool sameWS = false; - try { - sameWS = (matrixWS == m_instrumentActor->getWorkspace()); - } catch (std::runtime_error &) { - // Carry on, sameWS should stay false - } - // try to detect if the instrument changes (unlikely if the workspace // hasn't, but theoretically possible) - bool resetGeometry = matrixWS->getInstrument()->getNumberDetectors() != - m_instrumentActor->ndetectors(); - - // if workspace and instrument don't change keep the scaling - if (sameWS && !resetGeometry) { - m_instrumentActor->updateColors(); - setupColorMap(); - updateInstrumentView(); - } else { + bool resetGeometry = + matrixWS->detectorInfo().size() != m_instrumentActor->ndetectors(); + try { + if (matrixWS == m_instrumentActor->getWorkspace() && !resetGeometry) { + m_instrumentActor->updateColors(); + setupColorMap(); + updateInstrumentView(); + } + } catch (std::runtime_error &) { resetInstrument(resetGeometry); } }