mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 12:37:45 +08:00
Fix editor potentially using a track post-disposal
This changes the editor to track the current track as it is *loaded* by `MusicController`, rather than haphazardly following the current global `WorkingBeatmap` (with a potentially unloaded track) or relying on local immediate-load behaviour (as implemented in `ResourcesSection`).
This commit is contained in:
parent
2519706ad6
commit
2f60f91a0e
@ -70,7 +70,11 @@ namespace osu.Game.Overlays
|
||||
/// <summary>
|
||||
/// Forcefully reload the current <see cref="WorkingBeatmap"/>'s track from disk.
|
||||
/// </summary>
|
||||
public void ReloadCurrentTrack() => changeTrack();
|
||||
public void ReloadCurrentTrack()
|
||||
{
|
||||
changeTrack();
|
||||
TrackChanged?.Invoke(current, TrackChangeDirection.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the beatmap track is playing.
|
||||
|
@ -329,6 +329,9 @@ namespace osu.Game.Screens.Edit
|
||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private MusicController musicController { get; set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -336,12 +339,18 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
Mode.Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose;
|
||||
Mode.BindValueChanged(onModeChanged, true);
|
||||
|
||||
musicController.TrackChanged += onTrackChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the beatmap's track has changed, this method must be called to keep the editor in a valid state.
|
||||
/// </summary>
|
||||
public void UpdateClockSource() => clock.ChangeSource(Beatmap.Value.Track);
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
musicController.TrackChanged -= onTrackChanged;
|
||||
}
|
||||
|
||||
private void onTrackChanged(WorkingBeatmap working, TrackChangeDirection direction) => clock.ChangeSource(working.Track);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="EditorState"/> instance representing the current state of the editor.
|
||||
|
@ -118,8 +118,6 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
working.Value.Metadata.AudioFile = destination.Name;
|
||||
|
||||
music.ReloadCurrentTrack();
|
||||
|
||||
editor?.UpdateClockSource();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user