mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09: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 bool AllowSelection = true;
|
||||||
|
|
||||||
|
public void FlushPendingFilters()
|
||||||
|
{
|
||||||
|
if (filterTask?.Completed == false)
|
||||||
|
Filter(null, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void Filter(FilterCriteria newCriteria = null, bool debounce = true)
|
public void Filter(FilterCriteria newCriteria = null, bool debounce = true)
|
||||||
{
|
{
|
||||||
if (newCriteria != null)
|
if (newCriteria != null)
|
||||||
@ -263,6 +269,8 @@ namespace osu.Game.Screens.Select
|
|||||||
};
|
};
|
||||||
|
|
||||||
filterTask?.Cancel();
|
filterTask?.Cancel();
|
||||||
|
filterTask = null;
|
||||||
|
|
||||||
if (debounce)
|
if (debounce)
|
||||||
filterTask = Scheduler.AddDelayed(perform, 250);
|
filterTask = Scheduler.AddDelayed(perform, 250);
|
||||||
else
|
else
|
||||||
|
@ -198,13 +198,15 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void carouselRaisedStart()
|
private void carouselRaisedStart()
|
||||||
{
|
{
|
||||||
var pendingSelection = selectionChangedDebounce;
|
// if we have a pending filter operation, we want to run it now.
|
||||||
selectionChangedDebounce = null;
|
// it could change selection (ie. if the ruleset has been changed).
|
||||||
|
carousel.FlushPendingFilters();
|
||||||
|
|
||||||
if (pendingSelection?.Completed == false)
|
if (selectionChangedDebounce?.Completed == false)
|
||||||
{
|
{
|
||||||
pendingSelection.RunTask();
|
selectionChangedDebounce.RunTask();
|
||||||
pendingSelection.Cancel(); // cancel the already scheduled task.
|
selectionChangedDebounce.Cancel(); // cancel the already scheduled task.
|
||||||
|
selectionChangedDebounce = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnSelected();
|
OnSelected();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user