From 4a31ba390e69ff07a61eef6aae3d36753248ffb5 Mon Sep 17 00:00:00 2001 From: asv Date: Fri, 24 Jun 2005 12:32:44 +0000 Subject: [PATCH] Bug fixed: if 'splash' parameter is not set, then application crashed. Now OK. --- src/Session/SALOME_Session_Server.cxx | 9 ++++++--- src/Session/Session_ServerLauncher.cxx | 24 +++++++++++++----------- src/Session/Session_ServerLauncher.hxx | 4 +++- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 368b63c8d..621aada17 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -256,15 +256,16 @@ int main(int argc, char **argv) // CORBA Servant Launcher QMutex _GUIMutex ; - QWaitCondition _ServerLaunch; + QWaitCondition _ServerLaunch, _SessionStarted; _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); + = new Session_ServerLauncher(argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch, &_SessionStarted); myServerLauncher->start(); - _ServerLaunch.wait(&_GUIMutex); // to be reseased by Launch server thread when ready: + _ServerLaunch.wait(&_GUIMutex); // to be reseased by Launch server thread when ready + // show splash screen if "SPLASH" parameter was passed (default) if ( isFound( "SPLASH", argc, argv ) ) { @@ -290,6 +291,8 @@ int main(int argc, char **argv) if ( splash.getExitStatus() ) // 1 is error exit( splash.getExitStatus() ); // quit applicaiton } + else + _SessionStarted.wait(); // call Session::GetInterface() if "GUI" parameter was passed (default) if ( isFound( "GUI", argc, argv ) ) diff --git a/src/Session/Session_ServerLauncher.cxx b/src/Session/Session_ServerLauncher.cxx index b361fbf9e..b15f682a5 100755 --- a/src/Session/Session_ServerLauncher.cxx +++ b/src/Session/Session_ServerLauncher.cxx @@ -53,7 +53,8 @@ Session_ServerLauncher::Session_ServerLauncher(int argc, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex *GUIMutex, - QWaitCondition *ServerLaunch) + QWaitCondition *ServerLaunch, + QWaitCondition *SessionStarted) { _argc = argc; _argv = argv; @@ -61,6 +62,7 @@ Session_ServerLauncher::Session_ServerLauncher(int argc, _root_poa = PortableServer::POA::_duplicate(poa); _GUIMutex = GUIMutex; _ServerLaunch = ServerLaunch; + _SessionStarted = SessionStarted; } //============================================================================= @@ -81,14 +83,15 @@ Session_ServerLauncher::~Session_ServerLauncher() void Session_ServerLauncher::run() { - MESSAGE("****>>> Session_ServerLauncher::run"); _GUIMutex->lock(); // lock released by calling thread when ready: wait(mutex) - MESSAGE("****>>> Server Launcher thread free to go..."); - _GUIMutex->unlock(); - _ServerLaunch->wakeAll(); + _GUIMutex->unlock(); + _ServerLaunch->wakeAll(); + CheckArgs(); ActivateAll(); + _SessionStarted->wakeAll(); // wake main thread + _orb->run(); // this thread wait, during omniORB process events } @@ -195,7 +198,7 @@ void Session_ServerLauncher::ActivateAll() argv[i+1] = _argv[(*itServ)._firstArg + i]; } -std::cout << "*** activating [" << argc << "] : " << argv[0] << std::endl; + std::cout << "*** activating [" << argc << "] : " << argv[0] << std::endl; Session_ServerThread* aServerThread = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex); @@ -205,8 +208,7 @@ std::cout << "*** activating [" << argc << "] : " << argv[0] << std::endl; } // Always launch Session Server - -std::cout << "*** activating [ SESSION ] " << std::endl; + std::cout << "*** activating [ SESSION ] " << std::endl; int argc=1; char** argv = new char*[argc]; @@ -229,7 +231,7 @@ void Session_ServerLauncher::KillAll() MESSAGE("Session_ServerLauncher::KillAll()"); list::reverse_iterator itServ; for (itServ = _serverThreads.rbegin(); itServ !=_serverThreads.rend(); itServ++) - { - delete (*itServ); - } + { + delete (*itServ); + } } diff --git a/src/Session/Session_ServerLauncher.hxx b/src/Session/Session_ServerLauncher.hxx index 45804e17d..cb3bec809 100755 --- a/src/Session/Session_ServerLauncher.hxx +++ b/src/Session/Session_ServerLauncher.hxx @@ -62,7 +62,8 @@ public: CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex *GUIMutex, - QWaitCondition *ServerLaunch); + QWaitCondition *ServerLaunch, + QWaitCondition *SessionStarted); virtual ~Session_ServerLauncher(); void run(); void KillAll(); @@ -78,6 +79,7 @@ private: PortableServer::POA_var _root_poa; QMutex* _GUIMutex; QWaitCondition *_ServerLaunch; + QWaitCondition *_SessionStarted; list _argServToLaunch; vector _argCopy; list _serverThreads; -- 2.39.2