File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Assets/_PackageRoot/Runtime/Future Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments