From cc425176468e68de3487f947b5e31fa4eefaf6f4 Mon Sep 17 00:00:00 2001 From: philmoz Date: Thu, 27 Jun 2024 09:03:44 +1000 Subject: [PATCH] fix(color): crash when changing 'Mode' for 'Adjust' SF (#5219) --- radio/src/gui/colorlcd/special_functions.cpp | 15 +++++++-------- radio/src/thirdparty/libopenui/src/choice.cpp | 3 ++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/radio/src/gui/colorlcd/special_functions.cpp b/radio/src/gui/colorlcd/special_functions.cpp index 0255d7673..acd1e8cea 100644 --- a/radio/src/gui/colorlcd/special_functions.cpp +++ b/radio/src/gui/colorlcd/special_functions.cpp @@ -517,7 +517,13 @@ void FunctionEditPage::updateSpecialFunctionOneWindow() new StaticText(line, rect_t{}, STR_MODE); auto modechoice = new Choice(line, rect_t{}, FUNC_ADJUST_GVAR_CONSTANT, FUNC_ADJUST_GVAR_INCDEC, - GET_DEFAULT(CFN_GVAR_MODE(cfn)), nullptr); + GET_DEFAULT(CFN_GVAR_MODE(cfn)), + [=](int32_t newValue) { + CFN_GVAR_MODE(cfn) = newValue; + CFN_PARAM(cfn) = 0; + SET_DIRTY(); + updateSpecialFunctionOneWindow(); + }); line = specialFunctionOneWindow->newLine(grid); modechoice->setTextHandler([](int32_t value) { @@ -534,13 +540,6 @@ void FunctionEditPage::updateSpecialFunctionOneWindow() return std::string("---"); }); - modechoice->setSetValueHandler([=](int32_t newValue) { - CFN_GVAR_MODE(cfn) = newValue; - CFN_PARAM(cfn) = 0; - SET_DIRTY(); - updateSpecialFunctionOneWindow(); - }); - switch (CFN_GVAR_MODE(cfn)) { case FUNC_ADJUST_GVAR_CONSTANT: { int16_t val_min, val_max; diff --git a/radio/src/thirdparty/libopenui/src/choice.cpp b/radio/src/thirdparty/libopenui/src/choice.cpp index b0bd19978..40e519a3e 100644 --- a/radio/src/thirdparty/libopenui/src/choice.cpp +++ b/radio/src/thirdparty/libopenui/src/choice.cpp @@ -90,7 +90,8 @@ std::string Choice::getLabelText() void ChoiceBase::update() { - lv_label_set_text(label, getLabelText().c_str()); + if (!deleted()) + lv_label_set_text(label, getLabelText().c_str()); } Choice::Choice(Window* parent, const rect_t& rect, int vmin, int vmax,