fix potential null pointer access
This commit is contained in:
committed by
Raphael Coeffic
parent
29fcc8d0fd
commit
502b37a19a
+4
-2
@@ -29,8 +29,10 @@ void choicePaintCallback(lv_event_t *e)
|
||||
lv_obj_t *target = lv_event_get_target(e);
|
||||
if (target != nullptr) {
|
||||
ChoiceBase *cb = (ChoiceBase*)lv_obj_get_user_data(target);
|
||||
std::string text = cb->getLabelText();
|
||||
lv_label_set_text(cb->label, text.c_str());
|
||||
if (cb) {
|
||||
std::string text = cb->getLabelText();
|
||||
lv_label_set_text(cb->label, text.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-12
@@ -31,19 +31,21 @@ void menuBodyEventCallback(lv_event_t *e)
|
||||
if (target != nullptr) {
|
||||
long index = (long)lv_event_get_user_data(e);
|
||||
MenuBody *mb = (MenuBody *) lv_obj_get_user_data(lv_obj_get_parent(target));
|
||||
Menu *menu = mb->getParentMenu();
|
||||
if (index < (int)mb->lines.size()) {
|
||||
onKeyPress();
|
||||
if (menu->multiple) {
|
||||
if (mb->selectedIndex == index)
|
||||
mb->lines[index].onPress();
|
||||
else
|
||||
if (mb) {
|
||||
Menu *menu = mb->getParentMenu();
|
||||
if (index < (int)mb->lines.size()) {
|
||||
onKeyPress();
|
||||
if (menu->multiple) {
|
||||
if (mb->selectedIndex == index)
|
||||
mb->lines[index].onPress();
|
||||
else
|
||||
mb->setIndex(index);
|
||||
}
|
||||
else {
|
||||
mb->setIndex(index);
|
||||
}
|
||||
else {
|
||||
mb->setIndex(index);
|
||||
mb->lines[index].onPress();
|
||||
menu->deleteLater();
|
||||
mb->lines[index].onPress();
|
||||
menu->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user