From c6dac0cb0b4f05bdb28ac770e33bdfb74e936e10 Mon Sep 17 00:00:00 2001 From: isn Date: Tue, 15 Nov 2016 21:41:43 +0300 Subject: [PATCH] refs #1040 proper exception handling (streamOp) --- src/HYDROGUI/HYDROGUI_StreamOp.cxx | 54 +++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_StreamOp.h | 2 + src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 4 ++ 3 files changed, 60 insertions(+) diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 932065d6..2a178d83 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -38,6 +38,8 @@ #include #include #include +#include + #include #include @@ -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 ) diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.h b/src/HYDROGUI/HYDROGUI_StreamOp.h index cb45e50d..5e3a9160 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.h +++ b/src/HYDROGUI/HYDROGUI_StreamOp.h @@ -47,6 +47,8 @@ protected: virtual bool isToAbortOnApply() const { return false; } + virtual void apply(); + private slots: void onAddProfiles(); void onRemoveProfiles( const QStringList& ); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 9681b5a0..e19e9fad 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2702,6 +2702,10 @@ file cannot be correctly imported for an Obstacle definition. HYDROGUI_StreamOp + CREATE_STREAM_ERROR + Stream creation error + + CREATE_STREAM Create stream -- 2.39.2