Salome HOME
Windows porting
[modules/gui.git] / src / SUIT / SUIT_Session.cxx
index 082d49addffcdc87b3dbc5c4c2dcbc917925ce78..a9db903d08ce360045b6bf2b393e34c502130fda 100755 (executable)
 
 SUIT_Session* SUIT_Session::mySession = 0;
 
+/*! Constructor.*/
+
 SUIT_Session::SUIT_Session()
 : QObject(),
 myResMgr( 0 ),
 myHandler( 0 ),
-myActiveApp( 0 )
+myActiveApp( 0 ),
+myExitStatus( FROM_GUI )
 {
   SUIT_ASSERT( !mySession )
 
@@ -32,6 +35,7 @@ myActiveApp( 0 )
   myAppList.setAutoDelete( true );
 }
 
+/*!destructor. Clear applications list and set mySession to zero.*/
 SUIT_Session::~SUIT_Session()
 {
   myAppList.clear();
@@ -39,6 +43,7 @@ SUIT_Session::~SUIT_Session()
   mySession = 0;
 }
 
+/*! \retval return mySession */
 SUIT_Session* SUIT_Session::session()
 {
   return mySession;
@@ -193,29 +198,45 @@ 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();
   }
 }
 
+/*! \retval return myHandler*/
 SUIT_ExceptionHandler* SUIT_Session::handler() const
 {
   return myHandler;
 }
 
+/*! \retval return last error string.*/
 QString SUIT_Session::lastError() const
 {
   QString str;
@@ -231,6 +252,9 @@ QString SUIT_Session::lastError() const
   return str;
 }
 
+/*! Load library to session.
+ * \retval Loaded library.
+ */
 SUIT_Session::AppLib SUIT_Session::loadLibrary( const QString& name )
 {
   QString libFile = SUIT_Tools::library( name );
@@ -247,6 +271,7 @@ SUIT_Session::AppLib SUIT_Session::loadLibrary( const QString& name )
   return lib;
 }
 
+/*! \retval Return file name by application name.*/
 QString SUIT_Session::applicationName( const QString& str ) const
 {
 #ifdef WIN32