From: nds Date: Mon, 24 Aug 2015 09:05:33 +0000 (+0300) Subject: Abort operation correction, Cases are: 1. Deselect feature button in ToolBar, 2.... X-Git-Tag: V_1.4.0_beta4~277 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6156449367dbe2da7c80b03359bae7626846a402;p=modules%2Fshaper.git Abort operation correction, Cases are: 1. Deselect feature button in ToolBar, 2. "Cancel" in warning of abort dialog should not abort the current operation. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 03b29dd75..992e821cb 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -659,24 +659,20 @@ bool PartSet_Module::deleteObjects() void PartSet_Module::onFeatureTriggered() { - SessionPtr aMgr = ModelAPI_Session::get(); - // 1. check whether the delete should be processed in the module - ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); - bool isNestedOp = PartSet_SketcherMgr::isNestedCreateOperation(anOperation); - if (isNestedOp) { - // in case if in the viewer nothing is displayed, the create operation should not be - // comitted even if all values of the feature are initialized - if (!mySketchMgr->canDisplayCurrentCreatedFeature()) { - QAction* aCmd = dynamic_cast(sender()); - //Do nothing on uncheck - if (aCmd->isCheckable() && !aCmd->isChecked()) - return; - - // the action information should be saved before the operation is aborted - // because this abort leads to update command status, which unchecks this action - anOperation->abort(); - - launchOperation(aCmd->data().toString()); + QAction* aCmd = dynamic_cast(sender()); + if (aCmd->isCheckable() && aCmd->isChecked()) { + // 1. check whether the delete should be processed in the module + ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); + bool isNestedOp = PartSet_SketcherMgr::isNestedCreateOperation(anOperation); + if (isNestedOp) { + // in case if in the viewer nothing is displayed, the create operation should not be + // comitted even if all values of the feature are initialized + if (!mySketchMgr->canDisplayCurrentCreatedFeature()) { + // the action information should be saved before the operation is aborted + // because this abort leads to update command status, which unchecks this action + anOperation->abort(); + launchOperation(aCmd->data().toString()); + } } } ModuleBase_IModule::onFeatureTriggered(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index f7c5cfe3b..391ed7cdd 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -653,12 +653,13 @@ bool XGUI_Workshop::onSaveAs() void XGUI_Workshop::onUndo(int theTimes) { objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); - if (operationMgr()->canStopOperation()) - operationMgr()->abortOperation(operationMgr()->currentOperation()); - else - return; - SessionPtr aMgr = ModelAPI_Session::get(); + if (aMgr->isOperation()) { + /// this is important for nested operrations + /// when sketch opeation is active, this condition is false and + /// the sketch operation is not aborted + operationMgr()->onAbortOperation(); + } for (int i = 0; i < theTimes; ++i) { aMgr->undo(); } @@ -669,11 +670,6 @@ void XGUI_Workshop::onUndo(int theTimes) //****************************************************** void XGUI_Workshop::onRedo(int theTimes) { - if (operationMgr()->canStopOperation()) - operationMgr()->abortOperation(operationMgr()->currentOperation()); - else - return; - // the viewer update should be blocked in order to avoid the features blinking. For the created // feature a results are created, the flush of the created signal caused the viewer redisplay for // each created result. After a redisplay signal is flushed. So, the viewer update is blocked until @@ -682,6 +678,12 @@ void XGUI_Workshop::onRedo(int theTimes) objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); SessionPtr aMgr = ModelAPI_Session::get(); + if (aMgr->isOperation()) { + /// this is important for nested operrations + /// when sketch opeation is active, this condition is false and + /// the sketch operation is not aborted + operationMgr()->onAbortOperation(); + } for (int i = 0; i < theTimes; ++i) { aMgr->redo(); }