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 @@ 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);
}
}
}

View File

@ -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);
}
}