mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 05:58:35 +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 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 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 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
|
### MLEM.Data
|
||||||
Improvements
|
Improvements
|
||||||
|
|
|
@ -154,16 +154,22 @@ namespace MLEM.Ui.Parsers {
|
||||||
lock (bytesLock)
|
lock (bytesLock)
|
||||||
bytesNull = bytes == null;
|
bytesNull = bytes == null;
|
||||||
if (!bytesNull) {
|
if (!bytesNull) {
|
||||||
Texture2D tex;
|
Texture2D tex = null;
|
||||||
lock (bytesLock) {
|
lock (bytesLock) {
|
||||||
using (var stream = new MemoryStream(bytes)) {
|
try {
|
||||||
using (var read = Texture2D.FromStream(this.GraphicsDevice, stream))
|
using (var stream = new MemoryStream(bytes)) {
|
||||||
tex = read.PremultipliedCopy();
|
using (var read = Texture2D.FromStream(this.GraphicsDevice, stream))
|
||||||
|
tex = read.PremultipliedCopy();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
CatchOrRethrow(e);
|
||||||
}
|
}
|
||||||
bytes = null;
|
bytes = null;
|
||||||
}
|
}
|
||||||
image = new TextureRegion(tex);
|
if (tex != null) {
|
||||||
onImageFetched?.Invoke(image);
|
image = new TextureRegion(tex);
|
||||||
|
onImageFetched?.Invoke(image);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
|
@ -211,11 +217,15 @@ namespace MLEM.Ui.Parsers {
|
||||||
lock (bytesLock)
|
lock (bytesLock)
|
||||||
bytes = src;
|
bytes = src;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (this.ImageExceptionHandler != null) {
|
CatchOrRethrow(e);
|
||||||
this.ImageExceptionHandler.Invoke(path, e);
|
}
|
||||||
} else {
|
}
|
||||||
throw new NullReferenceException($"Couldn't parse image {path}, and no ImageExceptionHandler was set", e);
|
|
||||||
}
|
void CatchOrRethrow(Exception e) {
|
||||||
|
if (this.ImageExceptionHandler != null) {
|
||||||
|
this.ImageExceptionHandler.Invoke(path, e);
|
||||||
|
} else {
|
||||||
|
throw new NullReferenceException($"Couldn't parse image {path}, and no ImageExceptionHandler was set", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue