Julien Lebosquain
2 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
7 additions and
3 deletions
-
src/Avalonia.Base/Media/Imaging/Bitmap.cs
-
src/Avalonia.Base/Utilities/Ref.cs
|
|
|
@ -291,9 +291,7 @@ namespace Avalonia.Media.Imaging |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
// TODO12: We should probably make PlatformImpl to be nullable or make it possible to check
|
|
|
|
// and fix IRef<T> in general (right now Item is not nullable while it internally is)
|
|
|
|
if (PlatformImpl.Item == null!) |
|
|
|
if (!PlatformImpl.IsAlive) |
|
|
|
return null; |
|
|
|
return PlatformImpl; |
|
|
|
} |
|
|
|
|
|
|
|
@ -28,6 +28,10 @@ namespace Avalonia.Utilities |
|
|
|
/// <returns>A reference to the value as the new type but sharing the refcount.</returns>
|
|
|
|
IRef<TResult> CloneAs<TResult>() where TResult : class; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets whether the reference still tracks a valid item.
|
|
|
|
/// </summary>
|
|
|
|
bool IsAlive { get; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The current refcount of the object tracked in this reference. For debugging/unit test use only.
|
|
|
|
@ -172,6 +176,8 @@ namespace Avalonia.Utilities |
|
|
|
return new Ref<TResult>(item, counter); |
|
|
|
} |
|
|
|
|
|
|
|
public bool IsAlive => _item is not null; |
|
|
|
|
|
|
|
public int RefCount => _counter?.RefCount ?? throw new ObjectDisposedException("Ref<" + typeof(T) + ">"); |
|
|
|
} |
|
|
|
} |
|
|
|
|