From f6598a11e4c9e05a45e64d3cf9c2cd311226ed2c Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 28 Apr 2022 10:17:44 +0200 Subject: [PATCH] fix: static text lvobj NULL access --- radio/src/thirdparty/libopenui/src/static.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/static.cpp b/radio/src/thirdparty/libopenui/src/static.cpp index 88b69daf3..7fd9b9813 100644 --- a/radio/src/thirdparty/libopenui/src/static.cpp +++ b/radio/src/thirdparty/libopenui/src/static.cpp @@ -54,7 +54,7 @@ void StaticText::setText(std::string value) { if (text != value) { text = std::move(value); - lv_label_set_text(lvobj, text.c_str()); + if (lvobj) lv_label_set_text(lvobj, text.c_str()); } } @@ -66,10 +66,9 @@ const std::string& StaticText::getText() const void StaticText::setBackgroundColor(LcdFlags color) { bgColor = color; - auto actualColor = COLOR_VAL(bgColor); - lv_obj_set_style_bg_color( - lvobj, - lv_color_make(GET_RED(actualColor), GET_GREEN(actualColor), - GET_BLUE(actualColor)), - LV_PART_MAIN); + + if (!lvobj) return; + + lv_color_t c = makeLvColor(bgColor); + lv_obj_set_style_bg_color(lvobj, c, LV_PART_MAIN); }