1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:47:52 +08:00

Return tracker lease via UnbindAll()

Improves reliability by being fail-safe in case of multiple returns,
which can happen if the operation tracker is part of a screen being
exited (as is the case with its current primary usage in multiplayer).
This commit is contained in:
Bartłomiej Dach 2021-01-30 21:00:13 +01:00
parent 0aaa62efc2
commit 96f56d1c94

View File

@ -53,20 +53,15 @@ namespace osu.Game.Screens.OnlinePlay
// for extra safety, marshal the end of operation back to the update thread if necessary.
Scheduler.Add(() =>
{
leasedInProgress?.Return();
// UnbindAll() is purposefully used instead of Return() - the two do roughly the same thing, with one difference:
// the former won't throw if the lease has already been returned before.
// this matters because framework can unbind the lease via the internal UnbindAllBindables(), which is not always detectable
// (it is in the case of disposal, but not in the case of screen exit - at least not cleanly).
leasedInProgress?.UnbindAll();
leasedInProgress = null;
}, false);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
// base call does an UnbindAllBindables().
// clean up the leased reference here so that it doesn't get returned twice.
leasedInProgress = null;
}
private class OngoingOperation : IDisposable
{
private readonly OngoingOperationTracker tracker;