Skip to content

Commit e2942f2

Browse files
committed
Fixed disposing
1 parent 3019304 commit e2942f2

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Assets/_PackageRoot/Runtime/Future/Future.API.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ public void Cancel()
166166
if (ImageLoader.settings.debugLevel <= DebugLevel.Log && !muteLogs)
167167
Debug.Log($"[ImageLoader] Cancel: {Url}");
168168
Status = FutureStatus.Canceled;
169-
cts.Cancel();
170-
OnCanceled?.Invoke();
169+
if (!cts.IsCancellationRequested)
170+
{
171+
cts.Cancel();
172+
OnCanceled?.Invoke();
173+
}
171174
Clear();
172175
}
173176

@@ -176,17 +179,23 @@ public void Cancel()
176179
/// </summary>
177180
public void Dispose()
178181
{
179-
Clear();
182+
if (Status == FutureStatus.Disposed) return;
183+
if (!cts.IsCancellationRequested)
184+
{
185+
cts.Cancel();
186+
OnCanceled?.Invoke();
187+
}
180188
Status = FutureStatus.Disposed;
181189
OnDispose?.Invoke(this);
182190
OnDispose = null;
191+
Clear();
183192

184193
if (value is IDisposable disposable)
185194
disposable?.Dispose();
186195

187196
value = default;
188197
exception = default;
189-
cts.Cancel();
198+
190199
cts.Dispose();
191200
}
192201

Assets/_PackageRoot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Ivan Murzak",
66
"url": "https://github.com/IvanMurzak"
77
},
8-
"version": "5.3.2",
8+
"version": "5.3.3",
99
"unity": "2019.2",
1010
"description": "Asynchronous image loading from remote or local destination. It has two layers of configurable Memory and Disk cache systems.",
1111
"dependencies": {

0 commit comments

Comments
 (0)