Salome HOME
0022856: EDF 9971 PARAVIS: Error message not displayed in Paravis
[modules/gui.git] / src / Session / SALOME_Session_Server.cxx
index 439a516e15d5567915440c779eec235565d1a982..380ac23e8e91d1c03e68efd19081a7b0a091597e 100755 (executable)
@@ -46,6 +46,7 @@
 #include "Session_Session_i.hxx"
 
 #include <Qtx.h>
+#include <QtxMsgHandler.h>
 #include <QtxSplash.h>
 
 #ifdef USE_SALOME_STYLE
  * - stop Session ( must be idle )
  * - get session state
  */
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-void MessageOutput( QtMsgType type, const char* msg )
-#else
-void MessageOutput( QtMsgType type, const QMessageLogContext &context, const QString &msg )
-#endif
+
+class SessionMsgHandler: public QtxMsgHandlerCallback
 {
-  switch ( type )
+public:
+  SessionMsgHandler() {}
+  void qtMessage(QtMsgType type, const QMessageLogContext& context, const QString& message)
   {
-  case QtDebugMsg:
+    switch ( type )
+    {
+    case QtDebugMsg:
 #ifdef QT_DEBUG_MESSAGE
-    MESSAGE( "Debug: " << qPrintable( QString(msg) ) );
+      MESSAGE( "Debug: " << qPrintable( message ) );
 #endif
-    break;
-  case QtWarningMsg:
-    MESSAGE( "Warning: " << qPrintable( QString(msg) ) );
-    break;
-  case QtFatalMsg:
-    MESSAGE( "Fatal: " << qPrintable( QString(msg) ) );
-    break;
+      break;
+    case QtWarningMsg:
+      MESSAGE( "Warning: " << qPrintable( message ) );
+      break;
+    case QtCriticalMsg:
+      MESSAGE( "Critical: " << qPrintable( message ) );
+      break;
+    case QtFatalMsg:
+      MESSAGE( "Fatal: " << qPrintable( message ) );
+      break;
+    case QtInfoMsg:
+    default:
+      MESSAGE( "Information: " << qPrintable( message ) );
+      break;
+    }
   }
-}
+};
 
 QString salomeVersion()
 {
@@ -332,11 +342,8 @@ void shutdownServers( SALOME_NamingService* theNS )
 int main( int argc, char **argv )
 {
   // Install Qt debug messages handler
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-  qInstallMsgHandler( MessageOutput );
-#else
-  qInstallMessageHandler( MessageOutput );
-#endif
+  SessionMsgHandler msgHandler;
+  qInstallMessageHandler(QtxMsgHandler);
 
 // TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)