Skip to content

Commit 8ab8f58

Browse files
committed
Add debug logs for canceled and disposed futures in ImageLoader
1 parent 8b9ace5 commit 8ab8f58

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ public Future<T> Canceled(Action action)
139139
{
140140
if (IsCancelled)
141141
{
142+
if (ImageLoader.settings.debugLevel <= DebugLevel.Log && !muteLogs)
143+
Debug.Log($"[ImageLoader] Future[id={id}] Canceled: {Url}");
142144
action();
143145
return this;
144146
}
@@ -153,6 +155,13 @@ public Future<T> Canceled(Action action)
153155
/// <returns>Returns the Future instance</returns>
154156
public Future<T> Disposed(Action<Future<T>> action)
155157
{
158+
if (Status == FutureStatus.Disposed)
159+
{
160+
if (ImageLoader.settings.debugLevel <= DebugLevel.Log && !muteLogs)
161+
Debug.Log($"[ImageLoader] Future[id={id}] Disposed: {Url}");
162+
action?.Invoke(this);
163+
return this;
164+
}
156165
OnDispose += action;
157166
return this;
158167
}
@@ -195,7 +204,7 @@ public void Dispose()
195204
OnDispose = null;
196205
Clear();
197206

198-
if (value is IDisposable disposable)
207+
if (disposeValue && value is IDisposable disposable)
199208
disposable?.Dispose();
200209

201210
value = default;

Assets/_PackageRoot/Runtime/Future/Future.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public partial class Future<T> : IFuture, IDisposable
4242
public bool UseMemoryCache { get; private set; }
4343
private TimeSpan timeout;
4444
private bool cleared = false;
45+
private bool disposeValue = false;
4546
private T value = default;
4647
private Exception exception = default;
4748

0 commit comments

Comments
 (0)