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:
commit
d344452e9b
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user