Salome HOME
Multi column support for Object browser
[modules/gui.git] / src / SalomeApp / SalomeApp_Study.cxx
index de81f209175379d068eb96eb0d4c5767caa5989d..0ba477280f0f016308cc045ff753a1b85cb8ddbe 100644 (file)
 
 SalomeApp_Study::SalomeApp_Study( SUIT_Application* app )
 : CAM_Study( app )
-{}  
-
+{
+}  
 
 SalomeApp_Study::~SalomeApp_Study()
 {
-  closeDocument();
 }
 
 int SalomeApp_Study::id() const
@@ -40,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 ) );
@@ -188,9 +189,13 @@ void SalomeApp_Study::closeDocument()
   emit closed( this );
 
   // close SALOMEDS document
-  SalomeApp_Application::studyMgr()->Close( studyDS() );
-  SALOMEDSClient_Study* aStudy = NULL;
-  setStudyDS( _PTR(Study)(aStudy) );
+  _PTR(Study) studyPtr = studyDS();
+  if ( studyPtr )
+  {
+    SalomeApp_Application::studyMgr()->Close( studyPtr );
+    SALOMEDSClient_Study* aStudy = 0;
+    setStudyDS( _PTR(Study)(aStudy) );
+  }
 
   CAM_Study::closeDocument();
 }
@@ -255,7 +260,7 @@ void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm)
         aComp = aBuilder->NewComponent(dm->module()->name());
 
         // Set default engine IOR
-        aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1() );
+        aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1());
       }
     }
   }