From: mtn Date: Fri, 4 Oct 2013 08:04:15 +0000 (+0000) Subject: refs #32620. The closeSession order was updated X-Git-Tag: V5_2_9~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=20ec30859bbeb6fdeebb150f332c030bdbbc3907;p=modules%2Fgui.git refs #32620. The closeSession order was updated --- diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index c2715b470..a25ebd98c 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -420,6 +420,7 @@ bool STD_Application::closeAction( const int choice, bool& closePermanently ) res = false; break; case CloseDiscard: + emit saveDiscard(); break; case CloseCancel: default: diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index a1306377a..735273efe 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -107,6 +107,7 @@ public: signals: void applicationClosed( SUIT_Application* ); + void saveDiscard(); void activated( SUIT_Application* ); void infoChanged( QString ); diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index a11ea26a6..c190b1b91 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -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; } diff --git a/src/SUIT/SUIT_Session.h b/src/SUIT/SUIT_Session.h index e6ece73e3..03d943748 100755 --- a/src/SUIT/SUIT_Session.h +++ b/src/SUIT/SUIT_Session.h @@ -87,6 +87,7 @@ protected: private slots: void onApplicationClosed( SUIT_Application* ); void onApplicationActivated( SUIT_Application* ); + void onAppClosedDiscard(); private: typedef QList AppList;