Skip to content

Commit

Permalink
Merge pull request ppy#24691 from peppy/file-ipc-race-fix
Browse files Browse the repository at this point in the history
Fix potential race condition in song bar beatmap lookup flow
  • Loading branch information
bdach authored Aug 31, 2023
2 parents 0131296 + cf9c812 commit b5d8871
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ public void TestSongBar()

songBar.Beatmap = new TournamentBeatmap(beatmap);
});

AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock);
AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime);
AddStep("unset mods", () => songBar.Mods = LegacyMods.None);

AddToggleStep("toggle expanded", expanded => songBar.Expanded = expanded);

AddStep("set null beatmap", () => songBar.Beatmap = null);
}
}
}
12 changes: 10 additions & 2 deletions osu.Game.Tournament/IPC/FileBasedIPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,16 @@ private void load()
else
{
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b);
beatmapLookupRequest.Failure += _ => Beatmap.Value = null;
beatmapLookupRequest.Success += b =>
{
if (lastBeatmapId == beatmapId)
Beatmap.Value = new TournamentBeatmap(b);
};
beatmapLookupRequest.Failure += _ =>
{
if (lastBeatmapId == beatmapId)
Beatmap.Value = null;
};
API.Queue(beatmapLookupRequest);
}
}
Expand Down

0 comments on commit b5d8871

Please sign in to comment.