Salome HOME
Merge branch 'master' into V7_5_BR
[modules/gui.git] / src / SalomeApp / SalomeApp_Study.cxx
index 8bb0ee1785f29051cf0edeef6a67985afe47884c..ab6166997d6d3e58ccdbaa1433310d69d15368c4 100644 (file)
 
 #include <LightApp_Displayer.h>
 
+#ifndef DISABLE_PYCONSOLE
+  #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
+#endif
+
 #include "utilities.h"
 
 #include "SALOMEDS_Tool.hxx"
@@ -466,10 +470,17 @@ bool SalomeApp_Study::createDocument( const QString& theStr )
   try {
     study = _PTR(Study)( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) );
   }
+  catch(const SALOME_Exception& ex) {
+    SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
+                               tr("ERR_ERROR"), tr(ex.what()));
+    return false;
+  } 
   catch(...) {
     SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
-                               tr("ERR_ERROR"), tr("ERR_ACTIVE_STUDY_CREATE") );
+                               tr("ERR_ERROR"), tr("CREATE_DOCUMENT_PROBLEM"));
+    return false;
   }
+
   if ( !study )
     return false;
 
@@ -509,10 +520,17 @@ bool SalomeApp_Study::openDocument( const QString& theFileName )
   try {
     study = _PTR(Study) ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) );
   }
+  catch(const SALOME_Exception& ex) {
+    SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
+                               tr("ERR_ERROR"), tr(ex.what()));
+    return false;
+  } 
   catch(...) {
     SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
-                               tr("ERR_ERROR"), tr("ERR_ACTIVE_STUDY_OPEN") );
+                               tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM"));
+    return false;
   }
+
   if ( !study )
     return false;
 
@@ -715,7 +733,15 @@ void SalomeApp_Study::closeDocument(bool permanently)
     if ( myObserver )
       myStudyDS->detach( myObserver->_this() );
     if ( permanently ) {
+      SUIT_Desktop* desk = SUIT_Session::session()->activeApplication()->desktop();
+      bool isBlocked = desk->signalsBlocked();
+      desk->blockSignals( true );
       SalomeApp_Application::studyMgr()->Close( studyPtr );
+      desk->blockSignals( isBlocked );
+#ifndef DISABLE_PYCONSOLE
+      SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
+      app->getPyInterp()->destroy();
+#endif
     }
     SALOMEDSClient_Study* aStudy = 0;
     setStudyDS( _PTR(Study)(aStudy) );