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.
This commit is contained in:
Stenzek committed 2026-10-25 14:29:03 +10:00
1 parent b73f8b2731
commit 9bbf341beb
1 file changed
+5 -11
+5 -11
View File
@@ -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);
}
}