Salome HOME
studyActivated() virtual method has been added
[modules/gui.git] / src / SUIT / SUIT_Session.cxx
index 9dcef329a14af5edd78440d78d3189b6f9b0b372..d47b8d3e33ff94fda620db1b0657932aa76a0ecd 100755 (executable)
@@ -23,7 +23,8 @@ SUIT_Session::SUIT_Session()
 : QObject(),
 myResMgr( 0 ),
 myHandler( 0 ),
-myActiveApp( 0 )
+myActiveApp( 0 ),
+myExitStatus( FROM_GUI )
 {
   SUIT_ASSERT( !mySession )
 
@@ -66,7 +67,8 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int args,
     return 0;
   }
 
-  myAppLibs.insert( appName, libHandle );
+  if (!myAppLibs.contains(appName) || !myAppLibs[appName]) // jfa 22.06.2005
+    myAppLibs.insert( appName, libHandle );
 
   APP_CREATE_FUNC crtInst = 0;
 
@@ -90,7 +92,8 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int args,
     myResMgr->loadLanguage();
   }
 
-  SUIT_Application* anApp = crtInst( args, argv );
+  //jfa 22.06.2005:SUIT_Application* anApp = crtInst( args, argv );
+  SUIT_Application* anApp = crtInst();
   if ( !anApp )
   {
     SUIT_MessageBox::warn1(0, tr( "Error" ), tr( "Can not find function %1. %2").arg( APP_CREATE_NAME ).arg( lastError() ), tr( "Ok" ) );
@@ -191,19 +194,33 @@ void SUIT_Session::onApplicationClosed( SUIT_Application* theApp )
     myActiveApp = 0;
 
   if ( myAppList.isEmpty() )
-    qApp->quit();
+  {
+    printf( "Calling QApplication::exit() with exit code = %d\n", myExitStatus );
+    qApp->exit( myExitStatus );
+  }
 }
 
 /*!
   Destroys session by closing all applications.
 */
-void SUIT_Session::closeSession()
+void SUIT_Session::closeSession( int mode )
 {
   while ( !myAppList.isEmpty() )
   {
     SUIT_Application* app = myAppList.getFirst();
-    if ( !app->isPossibleToClose() )
+    if ( mode == ASK && !app->isPossibleToClose() )
       return;
+    else if ( mode == SAVE )
+    {
+      SUIT_Study* study = app->activeStudy();
+      if ( study->isModified() && study->isSaved() )
+       study->saveDocument();
+    }
+    else if ( mode == DONT_SAVE )
+    {
+      myExitStatus = FROM_CORBA_SESSION;
+      //....
+    }
 
     app->closeApplication();
   }