From 4b12d6397f2a39475854439da49411ea6c3e4d06 Mon Sep 17 00:00:00 2001 From: adv Date: Thu, 20 Mar 2014 11:50:06 +0000 Subject: [PATCH] Transaction mechanism for operations corrected. --- src/HYDROGUI/HYDROGUI_Operation.cxx | 23 ++++++++++++++++++----- src/HYDROGUI/HYDROGUI_Operation.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index de64a187..761083b8 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index be5f8e7f..05879abf 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -109,6 +109,7 @@ private: OCCViewer_ViewManager* myPreviewManager; QString myName; bool myIsPrintErrorMessage; + bool myIsTransactionOpened; int myPreviewZLayer; }; -- 2.39.2