1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 05:27:40 +08:00

Merge pull request #1041 from peppy/fix-carousel-debounce-race

Fix carousel filter debounce causing a race condition
This commit is contained in:
Dean Herbert 2017-07-21 17:57:47 +09:00 committed by GitHub
commit d344452e9b
2 changed files with 15 additions and 5 deletions

View File

@ -232,6 +232,12 @@ namespace osu.Game.Screens.Select
public bool AllowSelection = true;
public void FlushPendingFilters()
{
if (filterTask?.Completed == false)
Filter(null, false);
}
public void Filter(FilterCriteria newCriteria = null, bool debounce = true)
{
if (newCriteria != null)
@ -263,6 +269,8 @@ namespace osu.Game.Screens.Select
};
filterTask?.Cancel();
filterTask = null;
if (debounce)
filterTask = Scheduler.AddDelayed(perform, 250);
else

View File

@ -198,13 +198,15 @@ namespace osu.Game.Screens.Select
private void carouselRaisedStart()
{
var pendingSelection = selectionChangedDebounce;
selectionChangedDebounce = null;
// if we have a pending filter operation, we want to run it now.
// it could change selection (ie. if the ruleset has been changed).
carousel.FlushPendingFilters();
if (pendingSelection?.Completed == false)
if (selectionChangedDebounce?.Completed == false)
{
pendingSelection.RunTask();
pendingSelection.Cancel(); // cancel the already scheduled task.
selectionChangedDebounce.RunTask();
selectionChangedDebounce.Cancel(); // cancel the already scheduled task.
selectionChangedDebounce = null;
}
OnSelected();