Fix dialoged pushed to `DialogOverlay` too early potentially doing cross-thread transforms

As seen at https://github.com/ppy/osu/runs/6287700705?check_suite_focus=true.
This commit is contained in:
Dean Herbert 2022-05-04 20:22:52 +09:00
parent cf220f171b
commit 383245f43a
1 changed files with 12 additions and 8 deletions

View File

@ -47,6 +47,12 @@ private void load(AudioManager audio)
public void Push(PopupDialog dialog)
{
if (!IsLoaded)
{
Schedule(() => Push(dialog));
return;
}
if (dialog == CurrentDialog || dialog.State.Value != Visibility.Visible) return;
// if any existing dialog is being displayed, dismiss it before showing a new one.
@ -60,7 +66,7 @@ public void Push(PopupDialog dialog)
Show();
}
public override bool IsPresent => dialogContainer.Children.Count > 0;
public override bool IsPresent => Scheduler.HasPendingTasks || dialogContainer.Children.Count > 0;
protected override bool BlockNonPositionalInput => true;
@ -88,16 +94,14 @@ protected override void PopIn()
protected override void PopOut()
{
base.PopOut();
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
// PopOut is called as part of VisibilityContainer's initialisation logic, but we don't want it to interact with a potentially waiting dialog.
if (!IsLoaded) return;
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, 100, Easing.InCubic);
if (CurrentDialog?.State.Value == Visibility.Visible)
{
CurrentDialog.Hide();
return;
}
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
if (CurrentDialog?.State.Value == Visibility.Visible) CurrentDialog.Hide();
}
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)