UI: Avoid crash when atlas metadata is missing.

See #12722.
This commit is contained in:
Unknown W. Brackets committed 2020-03-21 21:10:20 -07:00
1 parent 0d2acb6d73
commit c65bfdffc6
2 files changed
+4 -1

No files matched your search

+1 -1
View File
@@ -818,7 +818,7 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
size_t atlas_data_size = 0;
if (!g_ui_atlas.IsMetadataLoaded()) {
const uint8_t *atlas_data = VFSReadFile("ui_atlas.meta", &atlas_data_size);
bool load_success = g_ui_atlas.Load(atlas_data, atlas_data_size);
bool load_success = atlas_data != nullptr && g_ui_atlas.Load(atlas_data, atlas_data_size);
_assert_msg_(G3D, load_success, "Failed to load ui_atlas.meta");
delete[] atlas_data;
}
+3
View File
@@ -250,6 +250,9 @@ inline void rot(float *v, float angle, float xc, float yc) {
void DrawBuffer::DrawImageRotated(ImageID atlas_image, float x, float y, float scale, float angle, Color color, bool mirror_h) {
const AtlasImage *image = atlas->getImage(atlas_image);
if (!image)
return;
float w = (float)image->w * scale;
float h = (float)image->h * scale;
float x1 = x - w / 2;