From da8e1022a014eab3a106a47adbb1a7170401b589 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 16 Jun 2021 18:00:23 +0200 Subject: [PATCH] ModelBmp hotfix --- radio/src/gui/colorlcd/widgets/modelbmp.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/radio/src/gui/colorlcd/widgets/modelbmp.cpp b/radio/src/gui/colorlcd/widgets/modelbmp.cpp index 4c2d96c12..daf5977f7 100644 --- a/radio/src/gui/colorlcd/widgets/modelbmp.cpp +++ b/radio/src/gui/colorlcd/widgets/modelbmp.cpp @@ -37,7 +37,9 @@ class ModelBitmapWidget: public Widget if (buffer && ((buffer->width() != width()) || (buffer->height() != height()) || (deps_hash != getHash()))) { + loadBitmap(); + deps_hash = getHash(); } // big space to draw @@ -84,18 +86,19 @@ class ModelBitmapWidget: public Widget std::string filename = std::string(g_model.header.bitmap); std::string fullpath = std::string(BITMAPS_PATH PATH_SEPARATOR) + filename; - std::unique_ptr bitmap(BitmapBuffer::loadBitmap(fullpath.c_str())); - if (!bitmap) { - TRACE("could not load bitmap '%s'", filename.c_str()); - return; - } - if (!buffer || (buffer->width() != width()) || (buffer->height() != height())) { buffer.reset(new BitmapBuffer(BMP_RGB565, width(), height())); } buffer->clear(DEFAULT_BGCOLOR); - buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38); + if (!filename.empty()) { + std::unique_ptr bitmap(BitmapBuffer::loadBitmap(fullpath.c_str())); + if (!bitmap) { + TRACE("could not load bitmap '%s'", filename.c_str()); + return; + } + buffer->drawScaledBitmap(bitmap.get(), 0, 38, width(), height() - 38); + } } };