mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-20 04:11:36 +08:00
fix(obj): fix segfault when obj_remove_flag is called for screen (#10104)
This commit is contained in:
+7
-2
@@ -307,15 +307,20 @@ void lv_obj_remove_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
||||
}
|
||||
|
||||
obj->flags &= (~f);
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
|
||||
if(f & LV_OBJ_FLAG_HIDDEN) {
|
||||
lv_obj_invalidate(obj);
|
||||
lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj));
|
||||
if(parent) {
|
||||
lv_obj_mark_layout_as_dirty(parent);
|
||||
}
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
}
|
||||
|
||||
if((was_on_layout != lv_obj_is_layout_positioned(obj)) || (f & (LV_OBJ_FLAG_LAYOUT_1 | LV_OBJ_FLAG_LAYOUT_2))) {
|
||||
lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj));
|
||||
if(parent) {
|
||||
lv_obj_mark_layout_as_dirty(parent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -237,4 +237,14 @@ void test_obj_flag_radio_button(void)
|
||||
|
||||
}
|
||||
|
||||
void test_obj_flag_parent_hidden(void)
|
||||
{
|
||||
/* #10083: Ensure that adding and removing screen flags don't make lvgl crash*/
|
||||
lv_obj_add_flag(lv_screen_active(), LV_OBJ_FLAG_HIDDEN);
|
||||
TEST_ASSERT_TRUE(lv_obj_has_flag(lv_screen_active(), LV_OBJ_FLAG_HIDDEN));
|
||||
lv_obj_remove_flag(lv_screen_active(), LV_OBJ_FLAG_HIDDEN);
|
||||
TEST_ASSERT_FALSE(lv_obj_has_flag(lv_screen_active(), LV_OBJ_FLAG_HIDDEN));
|
||||
TEST_PASS();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user