1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Merge pull request #24691 from peppy/file-ipc-race-fix

Fix potential race condition in song bar beatmap lookup flow
This commit is contained in:
Bartłomiej Dach 2023-08-31 21:54:38 +02:00 committed by GitHub
commit b5d88713fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -58,9 +58,14 @@ namespace osu.Game.Tournament.Tests.Components
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);
}
}
}

View File

@ -92,8 +92,16 @@ namespace osu.Game.Tournament.IPC
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);
}
}