From a211165b993cec59888b300199b44b525c0daf69 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 6 Mar 2020 11:30:30 +0300 Subject: [PATCH] Issue #18755 (Tuleap): Do not process key events if a modal window is displayed --- src/XGUI/XGUI_OperationMgr.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 347a7e62f..53c92f32f 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -94,9 +94,13 @@ public: } } else if (theEvent->type() == QEvent::KeyPress) { - QKeyEvent* aKeyEvent = dynamic_cast(theEvent); - myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier); - isAccepted = myOperationMgr->onKeyPressed(theObject, aKeyEvent); + if (!qApp->modalWindow()) { + if (myOperationMgr->hasOperation()) { + QKeyEvent* aKeyEvent = dynamic_cast(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(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(currentOperation()); + if (aFOperation) + aFOperation->setNeedToBeAborted(true); + } } } } -- 2.39.2