Skip to content

Commit

Permalink
Fixed disposing
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanMurzak committed May 13, 2024
1 parent 3019304 commit e2942f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions Assets/_PackageRoot/Runtime/Future/Future.API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ public void Cancel()
if (ImageLoader.settings.debugLevel <= DebugLevel.Log && !muteLogs)
Debug.Log($"[ImageLoader] Cancel: {Url}");
Status = FutureStatus.Canceled;
cts.Cancel();
OnCanceled?.Invoke();
if (!cts.IsCancellationRequested)
{
cts.Cancel();
OnCanceled?.Invoke();
}
Clear();
}

Expand All @@ -176,17 +179,23 @@ public void Cancel()
/// </summary>
public void Dispose()
{
Clear();
if (Status == FutureStatus.Disposed) return;
if (!cts.IsCancellationRequested)
{
cts.Cancel();
OnCanceled?.Invoke();
}
Status = FutureStatus.Disposed;
OnDispose?.Invoke(this);
OnDispose = null;
Clear();

if (value is IDisposable disposable)
disposable?.Dispose();

value = default;
exception = default;
cts.Cancel();

cts.Dispose();
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/_PackageRoot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Ivan Murzak",
"url": "https://github.com/IvanMurzak"
},
"version": "5.3.2",
"version": "5.3.3",
"unity": "2019.2",
"description": "Asynchronous image loading from remote or local destination. It has two layers of configurable Memory and Disk cache systems.",
"dependencies": {
Expand Down

0 comments on commit e2942f2

Please sign in to comment.