X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSession%2FSALOME_Session_Server.cxx;h=7e1c32f05a40fbab8db4e6a250019330fb5ff553;hb=33494e3cc0f15d5996e245e60855636cd28cb614;hp=c8465bfd0b5d1e01b283b6442b5466a9e85c2c91;hpb=630432f662544c0b3928874eb6825ba3bffa668b;p=modules%2Fgui.git diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index c8465bfd0..7e1c32f05 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -46,6 +46,7 @@ #include "Session_Session_i.hxx" #include +#include #include #ifdef USE_SALOME_STYLE @@ -77,9 +78,6 @@ #include #include #include -#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) -#include -#endif /*! - read arguments, define list of server to launch with their arguments. * - wait for naming service @@ -98,27 +96,36 @@ * - 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() { @@ -262,25 +269,30 @@ public: virtual bool notify( QObject* receiver, QEvent* e ) { - - try { - return myHandler ? myHandler->handle( receiver, e ) : QApplication::notify( receiver, e ); + QString debug_exceptions = ::getenv("SALOME_DEBUG_EXCEPTIONS"); + if ( debug_exceptions.length() > 0 ) { + return 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; + 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; } @@ -335,11 +347,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) @@ -371,12 +380,13 @@ int main( int argc, char **argv ) } #if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) - // initialization of the X11 visual on Linux - QSurfaceFormat format; - format.setDepthBufferSize(16); - format.setStencilBufferSize(1); - format.setProfile(QSurfaceFormat::CompatibilityProfile); - QSurfaceFormat::setDefaultFormat(format); + + // RNV: setup the default format: + // QSurfaceFormat should be set before creation of QApplication, + // so to avoid conflicts beetween SALOME and ParaView QSurfaceFormats we should merge theirs formats + // (see void Qtx::initDefaultSurfaceFormat()) and set the resultant format here. + Qtx::initDefaultSurfaceFormat(); + #endif // Create Qt application instance;