From c5fccb1499bdda8dc7db569a942e7cde12d5b0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Capello?= Date: Tue, 19 Oct 2021 15:36:07 -0300 Subject: [PATCH] Add a check to allow exit command execution only when the main window is the currently running --- src/app/modules/gui.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp index c802b4d66..53cfb8a62 100644 --- a/src/app/modules/gui.cpp +++ b/src/app/modules/gui.cpp @@ -458,9 +458,13 @@ bool CustomizedGuiManager::onProcessMessage(Message* msg) switch (msg->type()) { case kCloseDisplayMessage: { - // Execute the "Exit" command. - Command* command = Commands::instance()->byId(CommandId::Exit()); - UIContext::instance()->executeCommandFromMenuOrShortcut(command); + // Exit command is only allowed when the main window is the current + // window running. + if (getForegroundWindow() == App::instance()->mainWindow()) { + // Execute the "Exit" command. + Command* command = Commands::instance()->byId(CommandId::Exit()); + UIContext::instance()->executeCommandFromMenuOrShortcut(command); + } break; }