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
1 changed files with 5 additions and 5 deletions

View File

@ -50,17 +50,17 @@ public void Push(PopupDialog dialog)
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);