From 130fa028c7fa8a1db047f8a795433c9e1799b17a Mon Sep 17 00:00:00 2001
From: Tom Perkins <thomas.perkins@stfc.ac.uk>
Date: Tue, 8 Nov 2016 15:30:18 +0000
Subject: [PATCH] Clear fit model when switching multifit mode on/off

This makes sure that old fit models are not left floating around, and
avoids the situation that a fit function is set but not shown in the UI somehow.

re #17972
---
 .../src/Muon/MuonAnalysisFitFunctionPresenter.cpp              | 2 +-
 MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp          | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitFunctionPresenter.cpp b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitFunctionPresenter.cpp
index e4d1ce6f72c..bd9ce894b42 100644
--- a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitFunctionPresenter.cpp
+++ b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitFunctionPresenter.cpp
@@ -245,7 +245,7 @@ void MuonAnalysisFitFunctionPresenter::handleDatasetIndexChanged(int index) {
  * Turn multiple fitting mode on/off.
  * Turning it off hides the function browser and data selector so that
  * the fitting works as it used to pre-Mantid 3.8.
- * @param enabled :: [input] On/off for multiple fitting mode.
+ * @param state :: [input] On/off for multiple fitting mode.
  */
 void MuonAnalysisFitFunctionPresenter::setMultiFitState(
     Muon::MultiFitState state) {
diff --git a/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp b/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp
index fbb7614a20d..2e13796c66c 100644
--- a/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp
+++ b/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp
@@ -558,6 +558,9 @@ std::string MuonFitPropertyBrowser::outputName() const {
  * @param enabled :: [input] Whether to turn this mode on or off
  */
 void MuonFitPropertyBrowser::setMultiFittingMode(bool enabled) {
+  // First, clear whatever model is currently set
+  this->clear();
+
   // Show or hide "Function" and "Data" sections
   m_browser->setItemVisible(m_functionsGroup, !enabled);
   m_browser->setItemVisible(m_settingsGroup, !enabled);
-- 
GitLab