From 74643e2e7f012cf86aa67b6e4f4c2ad28dcea6df Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Mon, 8 Apr 2013 10:37:50 +0100
Subject: [PATCH] Show results on error. Refs #6202

---
 Code/Mantid/MantidPlot/src/ApplicationWindow.cpp          | 1 +
 Code/Mantid/MantidQt/API/inc/MantidQtAPI/MessageDisplay.h | 6 +++++-
 Code/Mantid/MantidQt/API/src/MessageDisplay.cpp           | 4 +++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
index f050f524b60..06e331799c0 100644
--- a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
+++ b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
@@ -284,6 +284,7 @@ void ApplicationWindow::init(bool factorySettings, const QStringList& args)
   qRegisterMetaType<Message>("Message"); // Required to use it in signals-slots
   resultsLog = new MantidQt::API::MessageDisplay(MessageDisplay::EnableLogLevelControl, logWindow);
   logWindow->setWidget(resultsLog);
+  connect(resultsLog, SIGNAL(errorReceived(const QString &)), logWindow, SLOT(show()));
 
   // Start Mantid
   // Set the Paraview path BEFORE libaries are loaded. Doing it here prevents
diff --git a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/MessageDisplay.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/MessageDisplay.h
index 20280d8b972..e3d154af900 100644
--- a/Code/Mantid/MantidQt/API/inc/MantidQtAPI/MessageDisplay.h
+++ b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/MessageDisplay.h
@@ -40,7 +40,7 @@ namespace MantidQt
       /// Controls whether the display is allowed to set the log levels
       enum LogLevelControl {
         EnableLogLevelControl = 0,
-        DisableLogLevelControl = 1
+        DisableLogLevelControl
       };
 
       /// Default constructor
@@ -52,6 +52,10 @@ namespace MantidQt
       // Setup logging framework connections
       void attachLoggingChannel();
 
+    signals:
+      /// Indicate that a message of error or higher has been received.
+      void errorReceived(const QString & text);
+
     public slots:
       /// Convenience method for appending message at fatal level
       void appendFatal(const QString & text);
diff --git a/Code/Mantid/MantidQt/API/src/MessageDisplay.cpp b/Code/Mantid/MantidQt/API/src/MessageDisplay.cpp
index f6f53b0967d..c6cd3ede7c6 100644
--- a/Code/Mantid/MantidQt/API/src/MessageDisplay.cpp
+++ b/Code/Mantid/MantidQt/API/src/MessageDisplay.cpp
@@ -125,6 +125,7 @@ namespace MantidQt
       appendText(msg.text());
       //set the colour back to the default (black) for historical reasons
       setTextColor(Message::Priority::PRIO_INFORMATION);
+      if(msg.priority() <= Message::Priority::PRIO_ERROR ) emit errorReceived(msg.text());
     }
 
     /**
@@ -132,7 +133,8 @@ namespace MantidQt
      */
     void MessageDisplay::replace(const Message & msg)
     {
-      m_textDisplay->setText(msg.text());
+      clear();
+      append(msg.text());
     }
 
     /**
-- 
GitLab