From 5415c85f8250d50b54c869ad712ef53796c58a29 Mon Sep 17 00:00:00 2001 From: adv Date: Thu, 29 Aug 2013 05:41:08 +0000 Subject: [PATCH] Main "Apply" principles for HYDRO operations corrected. --- src/HYDROGUI/HYDROGUI_Operation.cxx | 41 ++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 9bdf11e0..1b132b68 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -36,6 +36,8 @@ #include #include +#include + HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule ) : LightApp_Operation(), myModule( theModule ), @@ -82,8 +84,6 @@ void HYDROGUI_Operation::startOperation() { LightApp_Operation::startOperation(); - doc()->StartOperation(); - if( inputPanel() ) { myModule->getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, inputPanel() ); @@ -93,8 +93,6 @@ void HYDROGUI_Operation::startOperation() void HYDROGUI_Operation::abortOperation() { - doc()->AbortOperation(); - LightApp_Operation::abortOperation(); if( inputPanel() ) @@ -103,8 +101,6 @@ void HYDROGUI_Operation::abortOperation() void HYDROGUI_Operation::commitOperation() { - doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) ); - LightApp_Operation::commitOperation(); if( inputPanel() ) @@ -133,15 +129,46 @@ Handle_HYDROData_Document HYDROGUI_Operation::doc() const void HYDROGUI_Operation::onApply() { + QApplication::setOverrideCursor( Qt::WaitCursor ); + + // Open transaction in the model document + doc()->StartOperation(); + int anUpdateFlags = 0; QString anErrorMsg; - if( processApply( anUpdateFlags, anErrorMsg ) ) + + bool aResult = false; + + try + { + aResult = processApply( anUpdateFlags, anErrorMsg ); + } + 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 ); + + // Commit transaction in the model document + doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) ); commit(); } else { + // Abort transaction in the model document + doc()->AbortOperation(); + QString aMsg = tr( "INPUT_VALID_DATA" ); if( !anErrorMsg.isEmpty() ) aMsg.prepend( anErrorMsg + "\n" ); -- 2.30.2