mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-21 20:43:29 +01:00
Fixed UiParser ImageExceptionHandler being ignored when an exception occurs during texture construction
This commit is contained in:
parent
a58470de9f
commit
e1e1e8db8c
2 changed files with 22 additions and 11 deletions
|
@ -32,6 +32,7 @@ Fixes
|
|||
- Fixed tooltips not being bounded correctly for viewports that don't start at the origin
|
||||
- Fixed a stack overflow exception when a panel's children have just enough height to cause a scroll bar to appear
|
||||
- Fixed AddedToUi and RemovedFromUi being called for freshly added or removed children whose parents are not in a ui system
|
||||
- Fixed UiParser ImageExceptionHandler being ignored when an exception occurs during texture construction
|
||||
|
||||
### MLEM.Data
|
||||
Improvements
|
||||
|
|
|
@ -154,18 +154,24 @@ namespace MLEM.Ui.Parsers {
|
|||
lock (bytesLock)
|
||||
bytesNull = bytes == null;
|
||||
if (!bytesNull) {
|
||||
Texture2D tex;
|
||||
Texture2D tex = null;
|
||||
lock (bytesLock) {
|
||||
try {
|
||||
using (var stream = new MemoryStream(bytes)) {
|
||||
using (var read = Texture2D.FromStream(this.GraphicsDevice, stream))
|
||||
tex = read.PremultipliedCopy();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CatchOrRethrow(e);
|
||||
}
|
||||
bytes = null;
|
||||
}
|
||||
if (tex != null) {
|
||||
image = new TextureRegion(tex);
|
||||
onImageFetched?.Invoke(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}) {
|
||||
SetHeightBasedOnAspect = true,
|
||||
|
@ -211,6 +217,11 @@ namespace MLEM.Ui.Parsers {
|
|||
lock (bytesLock)
|
||||
bytes = src;
|
||||
} catch (Exception e) {
|
||||
CatchOrRethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
void CatchOrRethrow(Exception e) {
|
||||
if (this.ImageExceptionHandler != null) {
|
||||
this.ImageExceptionHandler.Invoke(path, e);
|
||||
} else {
|
||||
|
@ -218,7 +229,6 @@ namespace MLEM.Ui.Parsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A flags enumeration used by <see cref="UiParser"/> that contains the types of elements that can be parsed and returned in <see cref="Parse"/> or <see cref="ParseInto"/>.
|
||||
|
|
Loading…
Reference in a new issue