Salome HOME
debug IPAL9411: redefine virtual methods createEmptyStudy and activateModule
[modules/gui.git] / src / SalomeApp / SalomeApp_Study.cxx
index 0d6c28ae57b40eb64b0123cb8bd82367336eb81c..8b6f9019350346dbe664bd054a0abb256f9a80a3 100644 (file)
@@ -70,24 +70,20 @@ bool SalomeApp_Study::openDocument( const QString& theFileName )
 
   setStudyDS( study );
 
-  // build a SUIT_DataObject-s tree under myRoot member field
-  // 1. create myRoot
-  setRoot( new SalomeApp_RootObject( this ) );
-  // 2. iterate through all components and create corresponding sub-trees under them
-  _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() );
-  for ( ; it->More(); it->Next() ) {
-    // don't use shared_ptr here, for Data Object will take 
-    // ownership of this pointer
-    _PTR(SComponent) aComponent ( it->Value() ); 
+  setRoot( new SalomeApp_RootObject( this ) ); // create myRoot
 
-    if ( aComponent->ComponentDataType() == "Interface Applicative" )
-      continue; // skip the magic "Interface Applicative" component
-    
-    SalomeApp_DataModel::BuildTree( aComponent, root(), this );
-  }
+  // update loaded data models: call open() and update() on them.
+  ModelList dm_s;
+  dataModels( dm_s );
+  for ( ModelListIterator it( dm_s ); it.current(); ++it )
+    openDataModel( studyName(), it.current() );
 
-  bool res = CAM_Study::openDocument( theFileName );
+  // this will build a SUIT_DataObject-s tree under myRoot member field
+  // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
+  // but tree that corresponds to not-loaded data models will be updated any way. 
+  ((SalomeApp_Application*)application())->updateObjectBrowser( false ); 
 
+  bool res = CAM_Study::openDocument( theFileName );
   emit opened( this );
 
   return res;
@@ -120,16 +116,17 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName )
 
     if ( aComponent->ComponentDataType() == "Interface Applicative" )
       continue; // skip the magic "Interface Applicative" component
-    
+
     SalomeApp_DataModel::BuildTree( aComponent, root(), this );
   }
 
   // TODO: potentially unsafe call, since base study's openDocument() might try to access the file directly - to be improved
+  //bool res = true;
   bool res = CAM_Study::openDocument( theStudyName );
 
-  emit opened( this );
+  //emit opened( this );
 
-  return res;  
+  return res;
 }
 
 //=======================================================================
@@ -149,7 +146,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
    /* bool res = */isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) :
                   SalomeApp_Application::studyMgr()->SaveAs     ( theFileName.latin1(), studyDS(), isMultiFile );
 
-  bool res = res && CAM_Study::saveDocumentAs( theFileName );
+  bool res = CAM_Study::saveDocumentAs( theFileName );  //SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
 
   if ( res )
     emit saved( this );
@@ -183,7 +180,7 @@ void SalomeApp_Study::saveDocument()
 // Function : closeDocument
 // Purpose  : 
 //================================================================
-void SalomeApp_Study::closeDocument()
+void SalomeApp_Study::closeDocument(bool permanently)
 {
   // Inform everybody that this study is going to close when it's most safe to,
   // i.e. in the very beginning
@@ -193,12 +190,12 @@ void SalomeApp_Study::closeDocument()
   _PTR(Study) studyPtr = studyDS();
   if ( studyPtr )
   {
-    SalomeApp_Application::studyMgr()->Close( studyPtr );
+    if(permanently) SalomeApp_Application::studyMgr()->Close( studyPtr );
     SALOMEDSClient_Study* aStudy = 0;
     setStudyDS( _PTR(Study)(aStudy) );
   }
 
-  CAM_Study::closeDocument();
+  CAM_Study::closeDocument(permanently);
 }
 
 //================================================================