]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
BugID: PAL13069, added a map that contains IDs of created studies so that the studies...
authorsrn <srn@opencascade.com>
Tue, 8 Aug 2006 12:59:53 +0000 (12:59 +0000)
committersrn <srn@opencascade.com>
Tue, 8 Aug 2006 12:59:53 +0000 (12:59 +0000)
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_Study.cxx

index 5e73de8a68d0e045911a1063dcb3b84bd7447f67..b6e0fa83dbb2e3248e763b3f4c2e4c8538219034 100644 (file)
@@ -61,7 +61,6 @@
 #include <SALOME_ModuleCatalog_impl.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
 
-#include <qmap.h>
 #include <qaction.h>
 #include <qcombobox.h>
 #include <qlistbox.h>
@@ -81,6 +80,8 @@
 
 #include <SALOMEDSClient_ClientFactory.hxx>
 
+#include <vector>
+
 /*!Create new instance of SalomeApp_Application.*/
 extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
 {
@@ -91,6 +92,8 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
 SalomeApp_Application::SalomeApp_Application()
 : LightApp_Application()
 {
+  cout << "The constructor : " << this   << endl;
+  _studyIDs.clear();
 }
 
 /*!Destructor.
@@ -1103,3 +1106,33 @@ void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study )
     delete it.data();
 }
 
+/*!Adds a study Id to the map of stored IDs - to be closed on the application closing*/
+void SalomeApp_Application::addStudyId(const int theId)
+{ 
+  _studyIDs[theId] = 10;
+}
+
+/*!Removes a study Id from the map of stored IDs*/
+void SalomeApp_Application::removeStudyId(const int theId)
+{
+  _studyIDs.remove(theId);
+}
+
+
+
+/*!Iterates all opened study and closes them*/
+void SalomeApp_Application::closeApplication()
+{
+  std::vector<int> ids;
+  QMap<int, int>::Iterator it;
+  for (it = _studyIDs.begin(); it != _studyIDs.end(); it++) {
+    ids.push_back(it.key());
+  }
+
+  LightApp_Application::closeApplication();
+
+  for(int i = 0,sz = ids.size(); i<sz; i++) {
+    _PTR(Study) aStudy = studyMgr()->GetStudyByID(ids[i]);
+    if (aStudy) studyMgr()->Close(aStudy);
+  }
+}
index fbe0a84639810962b722756486179b11dd77353e..6106f3ee66be0e30b454dd3e89eabaeb569cfdc6 100644 (file)
@@ -31,6 +31,8 @@
 #include "SalomeApp.h"
 #include <LightApp_Application.h>
 
+#include <qmap.h>
+
 #include <CORBA.h>
 
 #include <SALOMEconfig.h>
@@ -90,6 +92,10 @@ public:
   SUIT_ViewManager*                   newViewManager(const QString&);
   void                                updateSavePointDataObjects( SalomeApp_Study* );
 
+  virtual void                        closeApplication();
+  void                                addStudyId(const int theId);
+  void                                removeStudyId(const int theId);
+
 public slots:
   virtual bool                        onOpenDoc( const QString& );
   virtual void                        onLoadDoc();
@@ -127,6 +133,11 @@ private slots:
   void                                onCatalogGen();
   void                                onRegDisplay();
   void                                onOpenWith();
+
+private:
+
+  QMap<int,int> _studyIDs;
+
 };
 
 #ifdef WIN32
index 6cbc7b34df9b6319d9a3d9d51fc7aaae9ec18e85..74adaf2add73014b5b77af281f17d17211d62082 100644 (file)
@@ -288,7 +288,14 @@ void SalomeApp_Study::closeDocument(bool permanently)
   _PTR(Study) studyPtr = studyDS();
   if ( studyPtr )
   {
-    if(permanently) SalomeApp_Application::studyMgr()->Close( studyPtr );
+    if(permanently) {
+      //SRN: bug 13069: If the study is closed permanently it is closed so remove its Id from the list of
+      //IDs of studies to be closed on the application closing
+      SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(application());
+      if(app) app->removeStudyId(studyPtr->StudyId());  
+      //SRN: End
+      SalomeApp_Application::studyMgr()->Close( studyPtr );
+    }
     SALOMEDSClient_Study* aStudy = 0;
     setStudyDS( _PTR(Study)(aStudy) );
   }
@@ -386,7 +393,13 @@ bool SalomeApp_Study::openStudyData( const QString& theFileName )
 */
 void SalomeApp_Study::setStudyDS( const _PTR(Study)& s )
 {
+   
   myStudyDS = s;
+
+  if(myStudyDS) {
+   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(application());
+   if(app) app->addStudyId(myStudyDS->StudyId()); //Add a new study Id
+  }
 }
 
 /*!