]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Transaction mechanism for operations corrected.
authoradv <adv@opencascade.com>
Thu, 20 Mar 2014 11:50:06 +0000 (11:50 +0000)
committeradv <adv@opencascade.com>
Thu, 20 Mar 2014 11:50:06 +0000 (11:50 +0000)
src/HYDROGUI/HYDROGUI_Operation.cxx
src/HYDROGUI/HYDROGUI_Operation.h

index de64a1878949e6d968c2e113e507a4ecb668d272..761083b8b64e90628ba81754c8d740b1d8119a6c 100644 (file)
@@ -45,6 +45,7 @@ HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule )
   myModule( theModule ),
   myPanel( 0 ),
   myIsPrintErrorMessage( true ),
+  myIsTransactionOpened( false ),
   myPreviewManager( 0 ),
   myPreviewZLayer( -1 )
 {
@@ -242,23 +243,35 @@ void HYDROGUI_Operation::processCancel()
 
 void HYDROGUI_Operation::startDocOperation()
 {
-  // Open transaction in the model document
+  // Open transaction in the model document only if it not
+  // already opened by other operation (intended for nested operations)
   if ( !doc()->IsOperation() )
+  {
     doc()->StartOperation();
+    myIsTransactionOpened = true;
+  }
 }
 
 void HYDROGUI_Operation::abortDocOperation()
 {
-  // Abort transaction in the model document
-  if ( doc()->IsOperation() )
+  // Abort transaction in the model document only if it was 
+  // opened by this operation (intended for nested operations)
+  if ( myIsTransactionOpened && doc()->IsOperation() )
+  {
     doc()->AbortOperation();
+    myIsTransactionOpened = false;
+  }
 }
 
 void HYDROGUI_Operation::commitDocOperation()
 {
-  // Commit transaction in the model document
-  if ( doc()->IsOperation() )
+  // Commit transaction in the model document only if it was 
+  // opened by this operation (intended for nested operations)
+  if ( myIsTransactionOpened && doc()->IsOperation() )
+  {
     doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) );
+    myIsTransactionOpened = false;
+  }
 }
 
 Handle_HYDROData_Document HYDROGUI_Operation::doc() const
index be5f8e7f4c0bcc2aac759ad7497a00cdd97887d6..05879abfc0ad272539dc1f61a88d7f58dd860160 100644 (file)
@@ -109,6 +109,7 @@ private:
   OCCViewer_ViewManager*              myPreviewManager;
   QString                             myName;
   bool                                myIsPrintErrorMessage;
+  bool                                myIsTransactionOpened;
   int                                 myPreviewZLayer;
 };