- try
- {
- SALOME_Event::GetSessionThread();
-
- CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
- PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
-
- PortableServer::POAManager_var pman = poa->the_POAManager() ;
- pman->activate() ;
- INFOS("pman->activate()");
-
- SALOME_NamingService *_NS = new SALOME_NamingService(orb);
-
- // CORBA Servant Launcher
- QMutex _GUIMutex ;
- QWaitCondition _ServerLaunch;
- _GUIMutex.lock(); // to block Launch server thread until wait(mutex)
-
- // 2. activate embedded CORBA servers: Registry, SALOMEDS, etc.
- Session_ServerLauncher* myServerLauncher
- = new Session_ServerLauncher(argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch);
- myServerLauncher->start();
-
- // 3. GUI activation
- // Allow multiple activation/deactivation of GUI
- //while ( 1 ) {
- MESSAGE("waiting wakeAll()");
- _ServerLaunch.wait(&_GUIMutex); // to be reseased by Launch server thread when ready:
- // atomic operation lock - unlock on mutex
- // unlock mutex: serverThread runs, calls _ServerLaunch->wakeAll()
- // this thread wakes up, and lock mutex
-
- INFOS("Session activated, Launch IAPP...");
- /*
- int qArgc = 1;
- argv[0] = (char*)_argv_0;
- SALOME_QApplication* _qappl = new SALOME_QApplication( qArgc, argv );
-
- QStringList lst = _qappl->libraryPaths();
- for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
- printf( "=====> Library path: %s\n", (*it).latin1() );
-
- _qappl->setStyle( "salome" );
-
- ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) );
- */
-
- INFOS("creation QApplication");
- _GUIMutex.unlock();
-
- // 3.1 SUIT_Session creation
- SUIT_Session* aGUISession = new SALOME_Session();
- INFOS("creation SUIT_Application");
-
- SCRUTE(_NS);
-
- // 3.3 run GUI loop
- // T2.12 - catch exceptions thrown on attempts to modified a locked study
- while (1) {
- try
- {
- MESSAGE("run(): starting the main event loop");
-
- // 3.2 load SalomeApp dynamic library
- SUIT_Application* aGUIApp = aGUISession->startApplication( "SalomeApp", 0, 0 );
- if ( aGUIApp )
- {
- _qappl.setHandler( aGUISession->handler() ); // after loading SalomeApp application
- // aGUISession contains SalomeApp_ExceptionHandler
- result = _qappl.exec();
- }
- break;
- }
- catch (SALOME::SALOME_Exception& e)
- {
- INFOS("run(): SALOME_Exception was caught!");
- QApplication::restoreOverrideCursor();
- SUIT_MessageBox::warn1 ( 0,
- QObject::tr("WRN_WARNING"),
- QObject::tr("SALOME_Exception was caught!"),
- QObject::tr("BUT_OK") );
- //QtCatchCorbaException(e);
- }
- catch(SALOMEDS::StudyBuilder::LockProtection&)
- {
- INFOS("run(): An attempt to modify a locked study has not been handled by QAD_Operation");
- QApplication::restoreOverrideCursor();
- SUIT_MessageBox::warn1 ( 0,
- QObject::tr("WRN_WARNING"),
- QObject::tr("WRN_STUDY_LOCKED"),
- QObject::tr("BUT_OK") );
- }
- catch (const CORBA::Exception& e)
- {
- CORBA::Any tmp;
- tmp<<= e;
- CORBA::TypeCode_var tc = tmp.type();
- const char *p = tc->name();
- INFOS ("run(): CORBA exception of the kind : "<<p<< " is caught");
-
- QApplication::restoreOverrideCursor();
- SUIT_MessageBox::error1 ( 0,
- QObject::tr("ERR_ERROR"),
- QObject::tr("ERR_APP_EXCEPTION")
- + QObject::tr(" CORBA exception ") + QObject::tr(p),
- QObject::tr("BUT_OK") );
- }
- catch(exception& e)
- {
- INFOS("run(): An exception has been caught");
- QApplication::restoreOverrideCursor();
- SUIT_MessageBox::error1 ( 0,
- QObject::tr("ERR_ERROR"),
- QObject::tr("ERR_APP_EXCEPTION")+ "\n" +QObject::tr(e.what()),
- QObject::tr("BUT_OK") );
- }
- catch(...)
- {
- INFOS("run(): An exception has been caught");
- QApplication::restoreOverrideCursor();
- SUIT_MessageBox::error1 ( 0,
- QObject::tr("ERR_ERROR"),
- QObject::tr("ERR_APP_EXCEPTION"),
- QObject::tr("BUT_OK") );
- }
- }
-//} end of "outer" while( 1 )