]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1040
authorisn <isn@opencascade.com>
Tue, 15 Nov 2016 18:41:43 +0000 (21:41 +0300)
committerisn <isn@opencascade.com>
Tue, 15 Nov 2016 18:42:25 +0000 (21:42 +0300)
proper exception handling (streamOp)

src/HYDROGUI/HYDROGUI_StreamOp.cxx
src/HYDROGUI/HYDROGUI_StreamOp.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 932065d607b84c07258dcb06a3d19005f16acdc2..2a178d83f96d97b3fb4936f6331e8c98c96f3b48 100755 (executable)
@@ -38,6 +38,8 @@
 #include <SUIT_MessageBox.h>
 #include <SUIT_Desktop.h>
 #include <QColor>
+#include <QApplication>
+
 
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
@@ -194,6 +196,58 @@ HYDROGUI_InputPanel* HYDROGUI_StreamOp::createInputPanel() const
   return aPanel;
 }
 
+void HYDROGUI_StreamOp::apply()
+{
+  QApplication::setOverrideCursor( Qt::WaitCursor );
+
+  startDocOperation();
+
+  int anUpdateFlags = 0;
+  QString anErrorMsg;
+
+  bool aResult = false;
+  QStringList aBrowseObjectsEntries;
+
+  try
+  {
+    aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
+  }
+  catch ( Standard_Failure )
+  {
+    Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
+    anErrorMsg = aFailure->GetMessageString();
+    aResult = false;
+  }
+  catch ( ... )
+  {
+    aResult = false;
+  }
+  
+  QApplication::restoreOverrideCursor();
+
+  if ( aResult )
+  {
+    module()->update( anUpdateFlags );
+    commitDocOperation();
+    commit();
+    browseObjects( aBrowseObjectsEntries );
+  }
+  else
+  {
+    myEditedObject->Remove();
+    module()->setObjectRemoved( myEditedObject );  
+
+    if ( isToAbortOnApply() )
+      abortDocOperation();
+
+    abort();
+    SUIT_MessageBox::critical( module()->getApp()->desktop(),
+                               tr( "CREATE_STREAM_ERROR" ),
+                               anErrorMsg ); 
+
+  } 
+}
+
 bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags,
                                       QString& theErrorMsg,
                                       QStringList& theBrowseObjectsEntries )
index cb45e50dc0cd10b46b68996520c42581d1d39720..5e3a91604460a1d834d3d8eef723d799fd5be64e 100755 (executable)
@@ -47,6 +47,8 @@ protected:
 
   virtual bool                 isToAbortOnApply() const { return false; }
 
+  virtual void                 apply();
+
 private slots:
   void                         onAddProfiles();
   void                         onRemoveProfiles( const QStringList& );
index 9681b5a0eb685240b67e05ccbc4928a1f0888f85..e19e9fad620280277b88133f4742e4af7bc5ed9e 100644 (file)
@@ -2702,6 +2702,10 @@ file cannot be correctly imported for an Obstacle definition.</translation>
   <context>
     <name>HYDROGUI_StreamOp</name>
     <message>
+      <source>CREATE_STREAM_ERROR</source>
+      <translation>Stream creation error</translation>
+    </message>
+     <message>
       <source>CREATE_STREAM</source>
       <translation>Create stream</translation>
     </message>