mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Merge pull request #4014 from smoogipoo/fix-match-select-crash
Fix null beatmap possibly being selected
This commit is contained in:
commit
7438fc19c8
@ -57,11 +57,19 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private class TestSongSelect : PlaySongSelect
|
private class TestSongSelect : PlaySongSelect
|
||||||
{
|
{
|
||||||
|
public Action StartRequested;
|
||||||
|
|
||||||
public new Bindable<RulesetInfo> Ruleset => base.Ruleset;
|
public new Bindable<RulesetInfo> Ruleset => base.Ruleset;
|
||||||
|
|
||||||
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
|
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
|
||||||
public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap;
|
public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap;
|
||||||
public new BeatmapCarousel Carousel => base.Carousel;
|
public new BeatmapCarousel Carousel => base.Carousel;
|
||||||
|
|
||||||
|
protected override bool OnStart()
|
||||||
|
{
|
||||||
|
StartRequested?.Invoke();
|
||||||
|
return base.OnStart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestSongSelect songSelect;
|
private TestSongSelect songSelect;
|
||||||
@ -182,6 +190,27 @@ namespace osu.Game.Tests.Visual
|
|||||||
void onRulesetChange(RulesetInfo ruleset) => rulesetChangeIndex = actionIndex--;
|
void onRulesetChange(RulesetInfo ruleset) => rulesetChangeIndex = actionIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStartAfterUnMatchingFilterDoesNotStart()
|
||||||
|
{
|
||||||
|
addManyTestMaps();
|
||||||
|
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "has selection");
|
||||||
|
|
||||||
|
bool startRequested = false;
|
||||||
|
|
||||||
|
AddStep("set filter and finalize", () =>
|
||||||
|
{
|
||||||
|
songSelect.StartRequested = () => startRequested = true;
|
||||||
|
|
||||||
|
songSelect.Carousel.Filter(new FilterCriteria { SearchText = "somestringthatshouldn'tbematchable" });
|
||||||
|
songSelect.FinaliseSelection();
|
||||||
|
|
||||||
|
songSelect.StartRequested = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("start not requested", () => !startRequested);
|
||||||
|
}
|
||||||
|
|
||||||
private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())));
|
private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())));
|
||||||
|
|
||||||
private static int importId;
|
private static int importId;
|
||||||
|
@ -297,14 +297,14 @@ namespace osu.Game.Screens.Select
|
|||||||
/// <param name="performStartAction">Whether to trigger <see cref="OnStart"/>.</param>
|
/// <param name="performStartAction">Whether to trigger <see cref="OnStart"/>.</param>
|
||||||
public void FinaliseSelection(BeatmapInfo beatmap = null, bool performStartAction = true)
|
public void FinaliseSelection(BeatmapInfo beatmap = null, bool performStartAction = true)
|
||||||
{
|
{
|
||||||
// avoid attempting to continue before a selection has been obtained.
|
|
||||||
// this could happen via a user interaction while the carousel is still in a loading state.
|
|
||||||
if (Carousel.SelectedBeatmap == null) return;
|
|
||||||
|
|
||||||
// if we have a pending filter operation, we want to run it now.
|
// if we have a pending filter operation, we want to run it now.
|
||||||
// it could change selection (ie. if the ruleset has been changed).
|
// it could change selection (ie. if the ruleset has been changed).
|
||||||
Carousel.FlushPendingFilterOperations();
|
Carousel.FlushPendingFilterOperations();
|
||||||
|
|
||||||
|
// avoid attempting to continue before a selection has been obtained.
|
||||||
|
// this could happen via a user interaction while the carousel is still in a loading state.
|
||||||
|
if (Carousel.SelectedBeatmap == null) return;
|
||||||
|
|
||||||
if (beatmap != null)
|
if (beatmap != null)
|
||||||
Carousel.SelectBeatmap(beatmap);
|
Carousel.SelectBeatmap(beatmap);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user