]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
refs #32620. The closeSession order was updated
authormtn <mtn@opencascade.com>
Fri, 4 Oct 2013 08:04:15 +0000 (08:04 +0000)
committermtn <mtn@opencascade.com>
Fri, 4 Oct 2013 08:04:15 +0000 (08:04 +0000)
src/STD/STD_Application.cxx
src/SUIT/SUIT_Application.h
src/SUIT/SUIT_Session.cxx
src/SUIT/SUIT_Session.h

index c2715b4700ff1daa03d18b2e9bf7b482907b84fe..a25ebd98c3871cf8efa0fd76f01e77918340c371 100755 (executable)
@@ -420,6 +420,7 @@ bool STD_Application::closeAction( const int choice, bool& closePermanently )
       res = false;
     break;
   case CloseDiscard:
+    emit saveDiscard();
     break;
   case CloseCancel:
   default:
index a1306377ae2fbca6a844bc2e60cf4bcd835132b1..735273efe36af59ab91bc1f5f57f08e18393fe30 100755 (executable)
@@ -107,6 +107,7 @@ public:
 
 signals:
   void                  applicationClosed( SUIT_Application* );
+  void                  saveDiscard();
   void                  activated( SUIT_Application* );
   void                  infoChanged( QString );
 
index a11ea26a624bde1a9079d4b3c40df2d4fcf7fcaf..c190b1b917996b50b4a91415febd67b56e2193ae 100755 (executable)
@@ -169,6 +169,7 @@ void SUIT_Session::insertApplication( SUIT_Application* app )
 
   connect( app, SIGNAL( applicationClosed( SUIT_Application* ) ),
            this, SLOT( onApplicationClosed( SUIT_Application* ) ) );
+  connect( app, SIGNAL( saveDiscard() ), this, SLOT( onAppClosedDiscard() ) );
   connect( app, SIGNAL( activated( SUIT_Application* ) ), 
                 this, SLOT( onApplicationActivated( SUIT_Application* ) ) );
 }
@@ -214,6 +215,15 @@ SUIT_ResourceMgr* SUIT_Session::resourceMgr() const
   return myResMgr;
 }
 
+/*!
+  Set exit status to forced in case of changes discarded.
+  If it is a last application the session will be closed.
+*/
+void SUIT_Session::onAppClosedDiscard()
+{
+  myExitStatus = FORCED;
+}
+
 /*!
   Removes the application from the list of launched applications.
   If it is a last application the session will be closed.
@@ -240,8 +250,20 @@ void SUIT_Session::onApplicationClosed( SUIT_Application* theApp )
 */
 void SUIT_Session::closeSession( int mode, int flags )
 {
+  myExitStatus = NORMAL;
   AppList apps = myAppList;
+  AppList aModifyedApps;
   for ( AppList::const_iterator it = apps.begin(); it != apps.end(); ++it )
+  {
+    SUIT_Application* app = *it;
+    SUIT_Study* study = app->activeStudy();
+    if( study ){
+      if( study->isModified() ){
+        aModifyedApps.append( app );
+      } 
+    }
+  }
+  for ( AppList::const_iterator it = aModifyedApps.begin(); it != aModifyedApps.end(); ++it )
   {
     SUIT_Application* app = *it;
     bool closePermanently;
@@ -260,7 +282,17 @@ void SUIT_Session::closeSession( int mode, int flags )
 
     app->closeApplication();
   }
-
+  for ( AppList::const_iterator it = myAppList.begin(); it != myAppList.end(); ++it ){
+    SUIT_Application* app = *it;
+    SUIT_Study* study = app->activeStudy();
+    if( study ){
+      if( study->isModified() ){
+        myExitStatus = FORCED;
+      } 
+      app->closeApplication();
+    }
+  }
+  
   myExitFlags = flags;
 }
 
index e6ece73e3447a46e9b2311c80962d6d6d38dd4ed..03d9437486ab0f73db71450007f4f8d14f75dfac 100755 (executable)
@@ -87,6 +87,7 @@ protected:
 private slots:
   void                         onApplicationClosed( SUIT_Application* );
   void                         onApplicationActivated( SUIT_Application* ); 
+  void                         onAppClosedDiscard();
 
 private:
   typedef QList<SUIT_Application*> AppList;