mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 15:27:20 +08:00
Schedule outside of UnloadStoryboard
and fix disposal happening on update thread
This commit is contained in:
parent
59998b507a
commit
080f13e34d
@ -71,7 +71,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
}, (loadCancellationSource = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
public void UnloadStoryboard(Action<Action> scheduleStoryboardRemoval)
|
||||
public void UnloadStoryboard()
|
||||
{
|
||||
if (drawableStoryboard == null)
|
||||
return;
|
||||
@ -79,15 +79,12 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
loadCancellationSource.AsNonNull().Cancel();
|
||||
loadCancellationSource = null;
|
||||
|
||||
DrawableStoryboard s = drawableStoryboard;
|
||||
|
||||
scheduleStoryboardRemoval(() =>
|
||||
{
|
||||
s.RemoveAndDisposeImmediately();
|
||||
Sprite.Alpha = 1f;
|
||||
});
|
||||
// clear is intentionally used here for the storyboard to be disposed asynchronously.
|
||||
storyboardContainer.Clear();
|
||||
|
||||
drawableStoryboard = null;
|
||||
|
||||
Sprite.Alpha = 1f;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -35,6 +35,6 @@ namespace osu.Game.Screens
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void ScheduleToTransitionEnd(Action action) => Scheduler.AddDelayed(action, BackgroundScreen.TRANSITION_LENGTH);
|
||||
internal ScheduledDelegate ScheduleUntilTransitionEnd(Action action) => Scheduler.AddDelayed(action, BackgroundScreen.TRANSITION_LENGTH);
|
||||
}
|
||||
}
|
||||
|
@ -73,13 +73,15 @@ namespace osu.Game.Screens.Backgrounds
|
||||
void next() => Next();
|
||||
}
|
||||
|
||||
private ScheduledDelegate storyboardUnloadDelegate;
|
||||
|
||||
public override void OnSuspending(ScreenTransitionEvent e)
|
||||
{
|
||||
var backgroundScreenStack = Parent as BackgroundScreenStack;
|
||||
Debug.Assert(backgroundScreenStack != null);
|
||||
|
||||
if (background is BeatmapBackgroundWithStoryboard storyboardBackground)
|
||||
storyboardBackground.UnloadStoryboard(backgroundScreenStack.ScheduleToTransitionEnd);
|
||||
storyboardUnloadDelegate = backgroundScreenStack.ScheduleUntilTransitionEnd(storyboardBackground.UnloadStoryboard);
|
||||
|
||||
base.OnSuspending(e);
|
||||
}
|
||||
@ -87,7 +89,14 @@ namespace osu.Game.Screens.Backgrounds
|
||||
public override void OnResuming(ScreenTransitionEvent e)
|
||||
{
|
||||
if (background is BeatmapBackgroundWithStoryboard storyboardBackground)
|
||||
storyboardBackground.LoadStoryboard();
|
||||
{
|
||||
if (storyboardUnloadDelegate?.Completed == false)
|
||||
storyboardUnloadDelegate.Cancel();
|
||||
else
|
||||
storyboardBackground.LoadStoryboard();
|
||||
|
||||
storyboardUnloadDelegate = null;
|
||||
}
|
||||
|
||||
base.OnResuming(e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user