Salome HOME
Merge branch 'ASL_TREE_STATE' into asl/hydro_porting_741
[modules/gui.git] / src / SalomeApp / SalomeApp_Study.cxx
index 070cfef7dfdaf3a0590347fbf8385ce1370e3ab0..70bd944cbdf7458bfc2b35f49957c6cbf107c4e3 100644 (file)
@@ -41,6 +41,9 @@
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_TreeModel.h>
 #include <SUIT_DataBrowser.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
 
 #include <LightApp_Displayer.h>
 
@@ -458,7 +461,22 @@ bool SalomeApp_Study::createDocument( const QString& theStr )
 
   // initialize myStudyDS, read HDF file
   QString aName = newStudyName();
-  _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) );
+
+  _PTR(Study) study;
+  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("CREATE_DOCUMENT_PROBLEM"));
+    return false;
+  }
+
   if ( !study )
     return false;
 
@@ -494,7 +512,21 @@ bool SalomeApp_Study::openDocument( const QString& theFileName )
   MESSAGE( "openDocument" );
 
   // initialize myStudyDS, read HDF file
-  _PTR(Study) study ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) );
+  _PTR(Study) study;
+  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("OPEN_DOCUMENT_PROBLEM"));
+    return false;
+  }
+
   if ( !study )
     return false;