-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix default beatmap not being correctly set after aborting new beatmap creation #32340
Conversation
…p creation Closes ppy#32337.
@@ -89,7 +89,7 @@ public void Invalidate(BeatmapInfo info) | |||
|
|||
public virtual WorkingBeatmap GetWorkingBeatmap([CanBeNull] BeatmapInfo beatmapInfo) | |||
{ | |||
if (beatmapInfo?.BeatmapSet == null) | |||
if (beatmapInfo?.ID == DefaultBeatmap.BeatmapInfo.ID || beatmapInfo?.BeatmapSet == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what it is precisely but I'm deeply uncomfortable with this id check. DefaultBeatmap
's ID isn't even fixed to some constant value, it just looks to be getting a random Guid.NewGuid()
via the default BeatmapInfo
ctor.
Is there any reason we can't go with something like the following instead?
diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs
index f56380a34d..925dd169e9 100644
--- a/osu.Game/Screens/Edit/Editor.cs
+++ b/osu.Game/Screens/Edit/Editor.cs
@@ -915,6 +915,9 @@ public override void OnSuspending(ScreenTransitionEvent e)
private void refetchBeatmap()
{
+ if (Beatmap.IsDefault)
+ return;
+
// To update the game-wide beatmap with any changes, perform a re-fetch on exit/suspend.
// This is required as the editor makes its local changes via EditorBeatmap
// (which are not propagated outwards to a potentially cached WorkingBeatmap).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do that as well, but I'd want to guard in WorkingBeatmapCache
as well, since this is bound to occur via some other means. Right now, doing a GetWorkingBeatmap
call will have a chance of converting a default/dummy beatmap into something that resembles it, but isn't considered default.
diff --git a/osu.Game/Beatmaps/WorkingBeatmapCache.cs b/osu.Game/Beatmaps/WorkingBeatmapCache.cs
index bd125deddf..30bbbbc1fe 100644
--- a/osu.Game/Beatmaps/WorkingBeatmapCache.cs
+++ b/osu.Game/Beatmaps/WorkingBeatmapCache.cs
@@ -89,7 +89,7 @@ public void Invalidate(BeatmapInfo info)
public virtual WorkingBeatmap GetWorkingBeatmap([CanBeNull] BeatmapInfo beatmapInfo)
{
- if (beatmapInfo?.ID == DefaultBeatmap.BeatmapInfo.ID || beatmapInfo?.BeatmapSet == null)
+ if (beatmapInfo == null || ReferenceEquals(beatmapInfo, DefaultBeatmap.BeatmapInfo))
return DefaultBeatmap;
lock (workingCache)
I'm guessing this will sit better with you? It seems to work just as well (waiting on tests to confirm that we don't need to check BeatmapSet
for null
, but it seems really weird that we would need to be).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it works then I suppose I could live with a reference equality check sure. Seems less prone to accidental breakage.
Closes #32337.
Also went down the path of ensuring we never have a placeholder track selected (https://github.com/ppy/osu/compare/master...peppy:osu:never-placeholder-beatmap?expand=1) but then saw that this case was already handled in the fail scenarios, and we were just incorrectly dereferencing the default beatmap instance via cache weirdness.