]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2250 Fatal error or sigsegv when I use the "Echap" key: Escape processed by...
authornds <nds@opencascade.com>
Fri, 29 Dec 2017 12:27:05 +0000 (15:27 +0300)
committernds <nds@opencascade.com>
Fri, 29 Dec 2017 12:27:05 +0000 (15:27 +0300)
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_OperationFeature.h
src/PartSet/PartSet_SketcherReentrantMgr.cpp
src/XGUI/XGUI_OperationMgr.cpp

index b04e209830ec3d40ec4d09cf757a6f5b26d21212..5a37bdd6731d6686aa78351976076bc08984e74c 100755 (executable)
@@ -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)
 {
 }
 
index cdb3675fc39ed878044a875878a244b6b54e63bd..0bdca8f4f7d3b7111478e09412f17506a23e73e4 100755 (executable)
@@ -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<std::shared_ptr<ModuleBase_ViewerPrs>> myPreSelection;
 
index eb524325c96653b8ecf5f50333cea99d89807747..b0d19549b987d7aab87e7248646d2a6fd2642ef9 100644 (file)
@@ -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();
   }
 }
 
index 6d77ef8a3a3b0e78904dc0744538d25e7b66471d..224e1c40e50945fbce1929b54ed377c0efd2cacd 100644 (file)
@@ -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<ModuleBase_OperationFeature*>(currentOperation());
+            if (aFOperation)
+              aFOperation->setNeedToBeAborted(true);
+          }
+        }
       }
       if (!isAccepted)
       {