From 8a1c6d3352dca695128396348866433613b2f5d4 Mon Sep 17 00:00:00 2001 From: Applin Date: Mon, 25 Mar 2024 13:45:42 +0000 Subject: [PATCH 1/2] Ensure a poco observer is only subscribed once to the Notification center --- qt/widgets/plotting/src/PreviewPlot.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/qt/widgets/plotting/src/PreviewPlot.cpp b/qt/widgets/plotting/src/PreviewPlot.cpp index 99d54d5bb9e6..230e7d240662 100644 --- a/qt/widgets/plotting/src/PreviewPlot.cpp +++ b/qt/widgets/plotting/src/PreviewPlot.cpp @@ -43,6 +43,16 @@ constexpr auto LOG_SCALE = "Log"; constexpr auto SQUARE_SCALE = "Square"; constexpr auto SHOWALLERRORS = "Show all errors"; constexpr auto HIDEALLERRORS = "Hide all errors"; + +template void modifyObserver(Observer &observer, bool const turnOn) { + auto ¬ificationCenter = AnalysisDataService::Instance().notificationCenter; + if (turnOn && !notificationCenter.hasObserver(observer)) { + notificationCenter.addObserver(observer); + } else if (!turnOn && notificationCenter.hasObserver(observer)) { + notificationCenter.removeObserver(observer); + } +} + } // namespace namespace MantidQt::MantidWidgets { @@ -77,14 +87,8 @@ PreviewPlot::~PreviewPlot() { watchADS(false); } * @param on If true ADS observers are enabled else they are disabled */ void PreviewPlot::watchADS(bool on) { - auto ¬ificationCenter = AnalysisDataService::Instance().notificationCenter; - if (on) { - notificationCenter.addObserver(m_wsRemovedObserver); - notificationCenter.addObserver(m_wsReplacedObserver); - } else { - notificationCenter.removeObserver(m_wsReplacedObserver); - notificationCenter.removeObserver(m_wsRemovedObserver); - } + modifyObserver(m_wsReplacedObserver, on); + modifyObserver(m_wsRemovedObserver, on); } /** From 033be36cf53647efa3f7b0749acdbc542ea606b3 Mon Sep 17 00:00:00 2001 From: Applin Date: Mon, 25 Mar 2024 13:50:19 +0000 Subject: [PATCH 2/2] Add release note --- docs/source/release/v6.9.1/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/release/v6.9.1/index.rst b/docs/source/release/v6.9.1/index.rst index bee08622220a..e0fc0a8c8171 100644 --- a/docs/source/release/v6.9.1/index.rst +++ b/docs/source/release/v6.9.1/index.rst @@ -15,6 +15,7 @@ The changes are: - Removed slit lookup that was specific to OFFSPEC in :ref:`algm-ReflectometryReductionOneLiveData` as it is no longer required and was causing regular crashes when running live data on OFFSPEC. - Fixed a bug in :ref:`Elwin Tab ` of :ref:`Data Manipulation Interface ` where changing integration range with the sliders did not change default integration range. - Add sample log values to the live data workspace before the instrument is loaded in :ref:`algm-ReflectometryReductionOneLiveData` to ensure log values are available when setting the detector positions. + - Fixed a crash when using multiple Indirect or Inelastic interfaces. This crash was present on the :ref:`Bayes Fitting ` interface, but could also be replicated elsewhere. Citation -------- @@ -36,6 +37,7 @@ Changes in this version * `37053 `_ Load instrument after loading sample logs in ReflectometryReductionOneLiveData * `37016 `_ Fix sliders not changing integration limits in Elwin tab * `36935 `_ Fix regular live data crashes on OFFSPEC +* `37074 `_ Fix crash on Indirect/Inelastic interfaces. .. _download page: http://download.mantidproject.org