From a9d601b424970cbb2ef1d393101e7fec1d713a3d Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 29 Dec 2017 15:27:05 +0300 Subject: [PATCH] Issue #2250 Fatal error or sigsegv when I use the "Echap" key: Escape processed by widget will require "abort" of operation (independently on whether the solver returns correct result or not). --- .../ModuleBase_OperationFeature.cpp | 3 +-- src/ModuleBase/ModuleBase_OperationFeature.h | 11 +++++++++++ src/PartSet/PartSet_SketcherReentrantMgr.cpp | 19 ++++++++++++------- src/XGUI/XGUI_OperationMgr.cpp | 8 ++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index b04e20983..5a37bdd67 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -60,8 +60,7 @@ #endif ModuleBase_OperationFeature::ModuleBase_OperationFeature(const QString& theId, QObject* theParent) -: ModuleBase_Operation(theId, theParent), - myIsEditing(false) +: ModuleBase_Operation(theId, theParent), myIsEditing(false), myNeedToBeAborted(false) { } diff --git a/src/ModuleBase/ModuleBase_OperationFeature.h b/src/ModuleBase/ModuleBase_OperationFeature.h index cdb3675fc..0bdca8f4f 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.h +++ b/src/ModuleBase/ModuleBase_OperationFeature.h @@ -140,6 +140,14 @@ Q_OBJECT /// \return theFeature a feature FeaturePtr previousCurrentFeature(); + /// Set whether the operation should be aborted. By default the state is false in operation + /// \param theState abort state + void setNeedToBeAborted(const bool theState) { myNeedToBeAborted = theState; } + + /// Returns valid state of the operation + /// \return custom validity state (it is almost always true) + bool isNeedToBeAborted() const { return myNeedToBeAborted; } + public slots: /// Starts operation /// Public slot. Verifies whether operation can be started and starts operation. @@ -186,6 +194,9 @@ Q_OBJECT /// Editing feature flag bool myIsEditing; + /// State used only if the operation should not be commited + bool myNeedToBeAborted; + /// List of pre-selected object QList> myPreSelection; diff --git a/src/PartSet/PartSet_SketcherReentrantMgr.cpp b/src/PartSet/PartSet_SketcherReentrantMgr.cpp index eb524325c..b0d19549b 100644 --- a/src/PartSet/PartSet_SketcherReentrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReentrantMgr.cpp @@ -365,15 +365,20 @@ void PartSet_SketcherReentrantMgr::onNoMoreWidgets(const std::string& thePreviou return; if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) { - bool isStarted = false; - if (!module()->sketchMgr()->sketchSolverError()) { - if (myRestartingMode != RM_Forbided) { - myRestartingMode = RM_LastFeatureUsed; - isStarted = startInternalEdit(thePreviousAttributeID); + if (aFOperation->isNeedToBeAborted()) { + aFOperation->abort(); + } + else { + bool isStarted = false; + if (!module()->sketchMgr()->sketchSolverError()) { + if (myRestartingMode != RM_Forbided) { + myRestartingMode = RM_LastFeatureUsed; + isStarted = startInternalEdit(thePreviousAttributeID); + } } + if (!isStarted) + aFOperation->commit(); } - if (!isStarted) - aFOperation->commit(); } } diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 6d77ef8a3..224e1c40e 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -714,7 +714,15 @@ bool XGUI_OperationMgr::onKeyPressed(QObject *theObject, QKeyEvent* theEvent) ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget(); if (anActiveWgt) + { isAccepted = anActiveWgt && anActiveWgt->processAction(ActionEscape); + if (isAccepted) { + ModuleBase_OperationFeature* aFOperation = + dynamic_cast(currentOperation()); + if (aFOperation) + aFOperation->setNeedToBeAborted(true); + } + } } if (!isAccepted) { -- 2.30.2