From: adv Date: Thu, 29 Aug 2013 05:41:08 +0000 (+0000) Subject: Main "Apply" principles for HYDRO operations corrected. X-Git-Tag: BR_hydro_v_0_1~95 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5415c85f8250d50b54c869ad712ef53796c58a29;p=modules%2Fhydro.git Main "Apply" principles for HYDRO operations corrected. --- 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" );