Add a check to allow exit command execution only when the main window is the currently running

This commit is contained in:
Martín Capello 2021-10-19 15:36:07 -03:00 committed by David Capello
parent f15589734f
commit c5fccb1499

View File

@ -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;
}