Skip to content

Commit

Permalink
fix random crash accessing disposed LoadedImageSource
Browse files Browse the repository at this point in the history
  • Loading branch information
taublast committed Nov 25, 2024
1 parent f1e7bd3 commit 1b81ebd
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions src/Engine/Draw/Images/LoadedImageSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,28 @@ public SKBitmap Bitmap
get => _bitmap;
set
{
_bitmap = value;
if (_bitmap == null)
if (!IsDisposed)
{
if (_image == null)
_bitmap = value;
if (_bitmap == null)
{
_height = 0;
_width = 0;
if (_image == null)
{
_height = 0;
_width = 0;
}
else
{
_height = _image.Height;
_width = _image.Width;
}
}
else
{
_height = _image.Height;
_width = _image.Width;
_height = _bitmap.Height;
_width = _bitmap.Width;
}
}
else
{
_height = _bitmap.Height;
_width = _bitmap.Width;
}
}
}

Expand All @@ -142,21 +145,24 @@ public SKImage Image
get => _image;
set
{
_image = value;
if (_image == null)
if (!IsDisposed)
{
if (_bitmap == null)
_image = value;
if (_image == null)
{
_height = 0;
_width = 0;
if (_bitmap == null)
{
_height = 0;
_width = 0;
}
}
}
else
{
if (_bitmap == null)
else
{
_height = _image.Height;
_width = _image.Width;
if (_bitmap == null)
{
_height = _image.Height;
_width = _image.Width;
}
}
}
}
Expand Down

0 comments on commit 1b81ebd

Please sign in to comment.