Salome HOME
Fix SIGSEGV on model.checkPythonDump() in GUI
[modules/shaper.git] / src / XGUI / XGUI_OperationMgr.cpp
index 44ea6cec2f7e68159cd51274946b22e7697ce8dc..e8ea75fa06285e197712614a4df74bef1db259cb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -29,6 +29,8 @@
 #include "XGUI_Tools.h"
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_ContextMenuMgr.h"
+#include "XGUI_Selection.h"
+#include "XGUI_SelectionMgr.h"
 
 #include <ModuleBase_IPropertyPanel.h>
 #include <ModuleBase_ModelWidget.h>
@@ -106,9 +108,16 @@ bool XGUI_ShortCutListener::eventFilter(QObject *theObject, QEvent *theEvent)
             isAccepted = myOperationMgr->onProcessDelete(theObject);
             break;
           case Qt::Key_F2:
-            myOperationMgr->xworkshop()->objectBrowser()->onEditItem();
+          {
+            QObjectPtrList anObjects = myOperationMgr->xworkshop()->selector()->selection()->selectedObjects();
+            if (myOperationMgr->xworkshop()->abortAllOperations())
+            {
+              myOperationMgr->xworkshop()->objectBrowser()->setObjectsSelected(anObjects);
+              myOperationMgr->xworkshop()->objectBrowser()->onEditItem();
+            }
             isAccepted = true;
             break;
+          }
           default:
             isAccepted = myOperationMgr->onKeyReleased(theObject, aKeyEvent);
             break;
@@ -133,7 +142,7 @@ bool XGUI_ShortCutListener::eventFilter(QObject *theObject, QEvent *theEvent)
 
 XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
   ModuleBase_IWorkshop* theWorkshop)
-: QObject(theParent), myWorkshop(theWorkshop), mySHIFTPressed(false), myActiveMessageBox(0)
+: QObject(theParent), myWorkshop(theWorkshop), myActiveMessageBox(0), mySHIFTPressed(false)
 {
   /// we need to install filter to the application in order to react to 'Delete' key button
   /// this key can not be a short cut for a corresponded action because we need to set
@@ -362,7 +371,7 @@ bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation,
   if (theOperation && theOperation->isModified()) {
     ModuleBase_OperationFeature* aOp = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
     std::string aContext;
-    if (aOp)
+    if (aOp && aOp->feature())
       aContext = aOp->feature()->getKind();
     QString aTitle = Config_Translator::translate(aContext,
       theOperation->getDescription()->description().toStdString()).c_str();
@@ -396,7 +405,6 @@ bool XGUI_OperationMgr::isGrantedOperation(const QString& theId)
 
   QListIterator<ModuleBase_Operation*> anIt(myOperations);
   anIt.toBack();
-  ModuleBase_Operation* aPreviousOperation = 0;
   while (anIt.hasPrevious() && !isGranted) {
     ModuleBase_Operation* anOp = anIt.previous();
     if (anOp)
@@ -475,9 +483,9 @@ void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
     // all operation from the current to triggered should also be aborted
     // operations over the parameter one are not aborted(e.g. extrusion cut, sketch abort)
     while(hasOperation()) {
-      ModuleBase_Operation* aCurrentOperation = currentOperation();
-      aCurrentOperation->abort();
-      if(theOperation == aCurrentOperation)
+      ModuleBase_Operation* aCurOperation = currentOperation();
+      aCurOperation->abort();
+      if(theOperation == aCurOperation)
         break;
     }
   }
@@ -731,7 +739,6 @@ bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent)
 bool XGUI_OperationMgr::onKeyPressed(QObject *theObject, QKeyEvent* theEvent)
 {
   // Let the manager decide what to do with the given key combination.
-  ModuleBase_Operation* anOperation = currentOperation();
   bool isAccepted = false;
   switch (theEvent->key()) {
     case Qt::Key_Escape: {