From 9bbf341bebf00549bf378edd8e5235e4d4abdcf8 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 25 Oct 2026 13:53:51 +1000 Subject: [PATCH] FullscreenUI: Copy/move checkable choice dialog callback before invoking If the callback reopened the dialog, it would destroy the running callback and the option it was passed. --- src/core/fullscreenui_widgets.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/core/fullscreenui_widgets.cpp b/src/core/fullscreenui_widgets.cpp index 7fda57c7f..2cf4543c9 100644 --- a/src/core/fullscreenui_widgets.cpp +++ b/src/core/fullscreenui_widgets.cpp @@ -5875,19 +5875,13 @@ void FullscreenUI::ChoiceDialog::Draw() if (choice >= 0) { // immediately close dialog when selecting, save the callback doing it. have to take a copy in this instance, - // because the callback may open another dialog, and we don't want to close that one. + // because the callback may open another dialog, and we don't want to close that one. checkable dialogs stay + // open, so the callback has to be kept for the next toggle. + const auto selected = m_options[choice]; + const ChoiceDialogCallback callback = m_checkable ? m_callback : std::exchange(m_callback, ChoiceDialogCallback()); if (!m_checkable) - { - const auto selected = m_options[choice]; - const ChoiceDialogCallback callback = std::exchange(m_callback, ChoiceDialogCallback()); StartClose(); - callback(choice, selected.first, selected.second); - } - else - { - const auto& option = m_options[choice]; - m_callback(choice, option.first, option.second); - } + callback(choice, selected.first, selected.second); } }