Salome HOME
Application::onLoadDoc() method implementation (for VISU batchmode tests)
[modules/gui.git] / src / SalomeApp / SalomeApp_Study.cxx
index c7dff3b6885e6a9968b98af391328621e9f6e95b..aa812a9748269d2397610c8de246c13cad61bbe6 100644 (file)
@@ -39,11 +39,13 @@ void SalomeApp_Study::createDocument()
   MESSAGE( "openDocument" );
 
   // initialize myStudyDS, read HDF file
-  _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( newStudyName().latin1() ) );
+  QString aName = newStudyName();
+  _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( aName.latin1() ) );
   if ( !study )
     return;
 
   setStudyDS( study );
+  setStudyName( aName );
 
   // create myRoot
   setRoot( new SalomeApp_RootObject( this ) );
@@ -118,16 +120,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;
 }
 
 //=======================================================================
@@ -142,14 +145,15 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
   for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() )
     aModel->saveAs( theFileName, this );
 
-  bool res = CAM_Study::saveDocumentAs( theFileName );
-
   // save SALOMEDS document
   bool isMultiFile = false, isAscii = false;// TODO: This information should be taken from preferences afterwards!
-  isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) :
-            SalomeApp_Application::studyMgr()->SaveAs     ( theFileName.latin1(), studyDS(), isMultiFile );
+   /* bool res = */isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) :
+                  SalomeApp_Application::studyMgr()->SaveAs     ( theFileName.latin1(), studyDS(), isMultiFile );
 
-  emit saved( this );
+  bool res = res && CAM_Study::saveDocumentAs( theFileName );
+
+  if ( res )
+    emit saved( this );
 
   return res;
 }
@@ -187,10 +191,10 @@ void SalomeApp_Study::closeDocument()
   emit closed( this );
 
   // close SALOMEDS document
-  _PTR(Study) st = studyDS();
-  if ( st.get() )
+  _PTR(Study) studyPtr = studyDS();
+  if ( studyPtr )
   {
-    SalomeApp_Application::studyMgr()->Close( st );
+    SalomeApp_Application::studyMgr()->Close( studyPtr );
     SALOMEDSClient_Study* aStudy = 0;
     setStudyDS( _PTR(Study)(aStudy) );
   }