]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #18755 (Tuleap): Do not process key events if a modal window is displayed
authorvsv <vsv@opencascade.com>
Fri, 6 Mar 2020 08:30:30 +0000 (11:30 +0300)
committervsv <vsv@opencascade.com>
Fri, 6 Mar 2020 08:30:30 +0000 (11:30 +0300)
src/XGUI/XGUI_OperationMgr.cpp

index 347a7e62fc7935b0067c9a752b2d7aa3755c8560..53c92f32f04e7e7a5d0d7110121b81e030727faf 100644 (file)
@@ -94,9 +94,13 @@ public:
         }
       }
       else if (theEvent->type() == QEvent::KeyPress) {
-        QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
-        myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier);
-        isAccepted = myOperationMgr->onKeyPressed(theObject, aKeyEvent);
+        if (!qApp->modalWindow()) {
+          if (myOperationMgr->hasOperation()) {
+            QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
+            myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier);
+            isAccepted = myOperationMgr->onKeyPressed(theObject, aKeyEvent);
+          }
+        }
       }
     }
     if (!isAccepted)
@@ -446,7 +450,7 @@ void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation, bool&
 void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
 {
   ModuleBase_Operation* aCurrentOperation = currentOperation();
-  if (theOperation == aCurrentOperation)
+  if (theOperation && (theOperation == aCurrentOperation))
     theOperation->abort();
   else {
     // it is possible to trigger upper operation(e.g. sketch, current is sketch line)
@@ -723,15 +727,17 @@ bool XGUI_OperationMgr::onKeyPressed(QObject *theObject, QKeyEvent* theEvent)
       ModuleBase_Operation* aOperation = currentOperation();
       if (!isAccepted && aOperation) {
         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 (aPanel) {
+          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);
+            }
           }
         }
       }