// Author : Paul RASCLE, EDF
// Module : SALOME
+#include <Container_init_python.hxx>
#include <SALOME_NamingService.hxx>
#include <SALOME_ModuleCatalog_impl.hxx>
#include <SALOME_LifeCycleCORBA.hxx>
#include <SALOME_Event.h>
-#include <Container_init_python.hxx>
#include <ConnectionManager_i.hxx>
#include <RegistryService.hxx>
#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()
{
virtual bool notify( QObject* receiver, QEvent* e )
{
-
- try {
- return myHandler ? myHandler->handle( receiver, e ) : QApplication::notify( receiver, e );
- }
- catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- }
- catch (CORBA::Exception& e) {
- std::cerr << "Caught CORBA::Exception" << std::endl;
- CORBA::Any tmp;
- tmp<<= e;
- CORBA::TypeCode_var tc = tmp.type();
- const char *p = tc->name();
- std::cerr << "notify(): CORBA exception of the kind : " << p << " is caught" << std::endl;
+ QString debug_exceptions = ::getenv("SALOME_DEBUG_EXCEPTIONS");
+ if ( debug_exceptions.length() > 0 ) {
+ return QApplication::notify( receiver, e );
}
- catch (...) {
- std::cerr << "Unknown exception caught in Qt handler: it's probably a bug in SALOME platform" << std::endl;
+ else {
+ try {
+ return myHandler ? myHandler->handle( receiver, e ) : QApplication::notify( receiver, e );
+ }
+ catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ catch (CORBA::Exception& e) {
+ std::cerr << "Caught CORBA::Exception" << std::endl;
+ CORBA::Any tmp;
+ tmp<<= e;
+ CORBA::TypeCode_var tc = tmp.type();
+ const char *p = tc->name();
+ std::cerr << "notify(): CORBA exception of the kind : " << p << " is caught" << std::endl;
+ }
+ catch (...) {
+ std::cerr << "Unknown exception caught in Qt handler: it's probably a bug in SALOME platform" << std::endl;
+ }
+ return false; // return false when exception is caught
}
- return false; // return false when exception is caught
}
SUIT_ExceptionHandler* handler() const { return myHandler; }
void setHandler( SUIT_ExceptionHandler* h ) { myHandler = h; }
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)