From 5becf25a79d194286169d5f83d17d2d411731f32 Mon Sep 17 00:00:00 2001 From: Yuriy Toporovskyy Date: Mon, 14 Jun 2021 12:14:58 -0400 Subject: [PATCH] Address some PR feedback. - Better comment explaining signal blocking - Clang format --- Code/Sandbox/Editor/MainWindow.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp index 4b0b0e104a..1ad97f31de 100644 --- a/Code/Sandbox/Editor/MainWindow.cpp +++ b/Code/Sandbox/Editor/MainWindow.cpp @@ -1273,11 +1273,24 @@ void MainWindow::OnGameModeChanged(bool inGameMode) menuBar()->setDisabled(inGameMode); m_toolbarManager->SetEnabled(!inGameMode); - // avoid a loop + // block signals on the switch to game actions before setting the checked state, as + // setting the checked state triggers the action, which will re-enter this function + // and result in an infinite loop AZStd::vector actions = { m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME), m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN) }; - for (auto action : actions) action->blockSignals(true); - for (auto action : actions) action->setChecked(inGameMode); - for (auto action : actions) action->blockSignals(false); + for (auto action : actions) + { + action->blockSignals(true); + } + + for (auto action : actions) + { + action->setChecked(inGameMode); + } + + for (auto action : actions) + { + action->blockSignals(false); + } } void MainWindow::OnEditorNotifyEvent(EEditorNotifyEvent ev)