From 2fd28b36c6f0c90fd6ad4efcd082b011b22b279b Mon Sep 17 00:00:00 2001
From: Lamar Moore <lamar.moore@stfc.ac.uk>
Date: Mon, 30 Apr 2018 13:03:24 +0100
Subject: [PATCH] small cleanup #22349

---
 .../instrumentview/src/InstrumentWidget.cpp   | 26 +++++++------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/qt/widgets/instrumentview/src/InstrumentWidget.cpp b/qt/widgets/instrumentview/src/InstrumentWidget.cpp
index ce2567b09b3..59e61ed9584 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);
       }
     }
-- 
GitLab