fix(obj) move clean ups from lv_obj_del to lv_obj_destructor
This commit is contained in:
@@ -401,6 +401,20 @@ static void lv_obj_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
_lv_event_mark_deleted(obj);
|
||||
|
||||
/*Remove all style*/
|
||||
lv_obj_enable_style_refresh(false); /*No need to refresh the style because the object will be deleted*/
|
||||
lv_obj_remove_style_all(obj);
|
||||
lv_obj_enable_style_refresh(true);
|
||||
|
||||
/*Remove the animations from this object*/
|
||||
lv_anim_del(obj, NULL);
|
||||
|
||||
/*Delete from the group*/
|
||||
lv_group_t * group = lv_obj_get_group(obj);
|
||||
if(group) lv_group_remove_obj(obj);
|
||||
|
||||
if(obj->spec_attr) {
|
||||
if(obj->spec_attr->children) {
|
||||
lv_mem_free(obj->spec_attr->children);
|
||||
@@ -414,7 +428,6 @@ static void lv_obj_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
lv_mem_free(obj->spec_attr);
|
||||
obj->spec_attr = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void lv_obj_draw(lv_event_t * e)
|
||||
|
||||
@@ -112,7 +112,6 @@ void lv_obj_class_init_obj(lv_obj_t * obj)
|
||||
|
||||
lv_group_t * def_group = lv_group_get_default();
|
||||
if(def_group && lv_obj_is_group_def(obj)) {
|
||||
|
||||
lv_group_add_obj(def_group, obj);
|
||||
}
|
||||
|
||||
@@ -127,7 +126,7 @@ void lv_obj_class_init_obj(lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
|
||||
void _lv_obj_destructor(lv_obj_t * obj)
|
||||
void _lv_obj_destruct(lv_obj_t * obj)
|
||||
{
|
||||
if(obj->class_p->destructor_cb) obj->class_p->destructor_cb(obj->class_p, obj);
|
||||
|
||||
@@ -136,7 +135,7 @@ void _lv_obj_destructor(lv_obj_t * obj)
|
||||
obj->class_p = obj->class_p->base_class;
|
||||
|
||||
/*Call the base class's destructor too*/
|
||||
_lv_obj_destructor(obj);
|
||||
_lv_obj_destruct(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +162,7 @@ bool lv_obj_is_group_def(lv_obj_t * obj)
|
||||
|
||||
return class_p->group_def == LV_OBJ_CLASS_GROUP_DEF_TRUE ? true : false;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
@@ -75,7 +75,7 @@ struct _lv_obj_t * lv_obj_class_create_obj(const struct _lv_obj_class_t * class_
|
||||
|
||||
void lv_obj_class_init_obj(struct _lv_obj_t * obj);
|
||||
|
||||
void _lv_obj_destructor(struct _lv_obj_t * obj);
|
||||
void _lv_obj_destruct(struct _lv_obj_t * obj);
|
||||
|
||||
bool lv_obj_is_editable(struct _lv_obj_t * obj);
|
||||
|
||||
|
||||
@@ -343,13 +343,6 @@ static void obj_del_core(lv_obj_t * obj)
|
||||
lv_res_t res = lv_event_send(obj, LV_EVENT_DELETE, NULL);
|
||||
if(res == LV_RES_INV) return;
|
||||
|
||||
/*Delete from the group*/
|
||||
lv_group_t * group = lv_obj_get_group(obj);
|
||||
if(group) lv_group_remove_obj(obj);
|
||||
|
||||
/*Remove the animations from this object*/
|
||||
lv_anim_del(obj, NULL);
|
||||
|
||||
/*Recursively delete the children*/
|
||||
lv_obj_t * child = lv_obj_get_child(obj, 0);
|
||||
while(child) {
|
||||
@@ -357,12 +350,7 @@ static void obj_del_core(lv_obj_t * obj)
|
||||
child = lv_obj_get_child(obj, 0);
|
||||
}
|
||||
|
||||
_lv_event_mark_deleted(obj);
|
||||
|
||||
/*Remove all style*/
|
||||
lv_obj_enable_style_refresh(false); /*No need to refresh the style because the object will be deleted*/
|
||||
lv_obj_remove_style_all(obj);
|
||||
lv_obj_enable_style_refresh(true);
|
||||
lv_group_t * group = lv_obj_get_group(obj);
|
||||
|
||||
/*Reset all input devices if the object to delete is used*/
|
||||
lv_indev_t * indev = lv_indev_get_next(NULL);
|
||||
@@ -381,7 +369,7 @@ static void obj_del_core(lv_obj_t * obj)
|
||||
}
|
||||
|
||||
/*All children deleted. Now clean up the object specific data*/
|
||||
_lv_obj_destructor(obj);
|
||||
_lv_obj_destruct(obj);
|
||||
|
||||
/*Remove the screen for the screen list*/
|
||||
if(obj->parent == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user