mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 14:25:10 +08:00
Fix infinite loop when switching audio tracks fails on an existing beatmap
Bit ugly, but appears to work in practice...
This commit is contained in:
parent
01ae1a58f1
commit
be9c96c041
@ -203,16 +203,40 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
editor?.Save();
|
||||
}
|
||||
|
||||
// to avoid scaring users, both background & audio choosers use fake `FileInfo`s with user-friendly filenames
|
||||
// when displaying an imported beatmap rather than the actual SHA-named file in storage.
|
||||
// however, that means that when a background or audio file is chosen that is broken or doesn't exist on disk when switching away from the fake files,
|
||||
// the rollback could enter an infinite loop, because the fake `FileInfo`s *also* don't exist on disk - at least not in the fake location they indicate.
|
||||
// to circumvent this issue, just allow rollback to proceed always without actually running any of the change logic to ensure visual consistency.
|
||||
// note that this means that `Change{BackgroundImage,AudioTrack}()` are required to not have made any modifications to the beatmap files
|
||||
// (or at least cleaned them up properly themselves) if they return `false`.
|
||||
private bool rollingBackBackgroundChange;
|
||||
private bool rollingBackAudioChange;
|
||||
|
||||
private void backgroundChanged(ValueChangedEvent<FileInfo?> file)
|
||||
{
|
||||
if (rollingBackBackgroundChange)
|
||||
return;
|
||||
|
||||
if (file.NewValue == null || !ChangeBackgroundImage(file.NewValue, backgroundChooser.ApplyToAllDifficulties.Value))
|
||||
{
|
||||
rollingBackBackgroundChange = true;
|
||||
backgroundChooser.Current.Value = file.OldValue;
|
||||
rollingBackBackgroundChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void audioTrackChanged(ValueChangedEvent<FileInfo?> file)
|
||||
{
|
||||
if (rollingBackAudioChange)
|
||||
return;
|
||||
|
||||
if (file.NewValue == null || !ChangeAudioTrack(file.NewValue, audioTrackChooser.ApplyToAllDifficulties.Value))
|
||||
{
|
||||
rollingBackAudioChange = true;
|
||||
audioTrackChooser.Current.Value = file.OldValue;
|
||||
rollingBackAudioChange = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user