mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:12:57 +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:
parent
0aaa62efc2
commit
96f56d1c94
@ -53,20 +53,15 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
// for extra safety, marshal the end of operation back to the update thread if necessary.
|
// for extra safety, marshal the end of operation back to the update thread if necessary.
|
||||||
Scheduler.Add(() =>
|
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;
|
leasedInProgress = null;
|
||||||
}, false);
|
}, 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 class OngoingOperation : IDisposable
|
||||||
{
|
{
|
||||||
private readonly OngoingOperationTracker tracker;
|
private readonly OngoingOperationTracker tracker;
|
||||||
|
Loading…
Reference in New Issue
Block a user