1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00

Fix CurrentDialog being updated twice, unsafe variable access

This commit is contained in:
Dean Herbert 2022-05-05 14:55:05 +09:00
parent a27fcda9f1
commit 326ff3b6e9

View File

@ -50,17 +50,17 @@ namespace osu.Game.Overlays
if (dialog == CurrentDialog || dialog.State.Value != Visibility.Visible) return;
var lastDialog = CurrentDialog;
// Immediately update the externally accessible property as this may be used for checks even before
// a DialogOverlay instance has finished loading.
CurrentDialog = dialog;
Scheduler.Add(() =>
{
// if any existing dialog is being displayed, dismiss it before showing a new one.
lastDialog?.Hide();
CurrentDialog = dialog;
CurrentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
dialogContainer.Add(CurrentDialog);
dialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
dialogContainer.Add(dialog);
Show();
}, false);