fix(copy): fix copying spec_attrs in lv_obj_create
This commit is contained in:
@@ -265,34 +265,40 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
|
|
||||||
lv_style_list_init(&new_obj->style_list);
|
lv_style_list_init(&new_obj->style_list);
|
||||||
lv_style_list_init(&new_obj->style_list);
|
lv_style_list_init(&new_obj->style_list);
|
||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
if(parent != NULL) lv_theme_apply(new_obj, LV_THEME_OBJ);
|
if(parent != NULL) lv_theme_apply(new_obj, LV_THEME_OBJ);
|
||||||
else lv_theme_apply(new_obj, LV_THEME_SCR);
|
else lv_theme_apply(new_obj, LV_THEME_SCR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lv_style_list_copy(&new_obj->style_list, ©->style_list);
|
lv_style_list_copy(&new_obj->style_list, ©->style_list);
|
||||||
}
|
}
|
||||||
/*Copy the attributes if required*/
|
/*Copy the attributes if required*/
|
||||||
if(copy != NULL) {
|
if(copy != NULL) {
|
||||||
lv_area_copy(&new_obj->coords, ©->coords);
|
lv_area_copy(&new_obj->coords, ©->coords);
|
||||||
new_obj->ext_draw_pad = copy->ext_draw_pad;
|
new_obj->ext_draw_pad = copy->ext_draw_pad;
|
||||||
|
|
||||||
new_obj->flags = copy->flags;
|
new_obj->flags = copy->flags;
|
||||||
|
if(copy->spec_attr) {
|
||||||
|
lv_obj_allocate_rare_attr(new_obj);
|
||||||
|
_lv_memcpy_small(new_obj->spec_attr, copy->spec_attr, sizeof(lv_obj_spec_attr_t));
|
||||||
|
}
|
||||||
|
#if LV_USE_GROUP
|
||||||
|
/*Add to the same group*/
|
||||||
|
if(copy->spec_attr && copy->spec_attr->group_p) {
|
||||||
|
new_obj->spec_attr->group_p = NULL; /*It was simply copied */
|
||||||
|
lv_group_add_obj(copy->spec_attr->group_p, new_obj);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LV_USE_GROUP
|
/*Set the same coordinates for non screen objects*/
|
||||||
/*Add to the same group*/
|
if(lv_obj_get_parent(copy) != NULL && parent != NULL) {
|
||||||
if(copy->spec_attr && copy->spec_attr->group_p) {
|
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
|
||||||
lv_group_add_obj(copy->spec_attr->group_p, new_obj);
|
lv_obj_set_size(new_obj, lv_obj_get_width(copy), lv_obj_get_height(copy));
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*Set the same coordinates for non screen objects*/
|
|
||||||
if(lv_obj_get_parent(copy) != NULL && parent != NULL) {
|
|
||||||
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lv_obj_set_pos(new_obj, 0, 0);
|
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lv_obj_set_pos(new_obj, 0, 0);
|
||||||
|
}
|
||||||
/*Send a signal to the parent to notify it about the new child*/
|
/*Send a signal to the parent to notify it about the new child*/
|
||||||
if(parent != NULL) {
|
if(parent != NULL) {
|
||||||
parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, new_obj);
|
parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, new_obj);
|
||||||
@@ -2001,10 +2007,12 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
|||||||
obj->ext_draw_pad = LV_MATH_MAX(obj->ext_draw_pad, d);
|
obj->ext_draw_pad = LV_MATH_MAX(obj->ext_draw_pad, d);
|
||||||
}
|
}
|
||||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||||
if(_lv_obj_is_grid_item(obj)) _lv_grid_full_refresh(obj);
|
if(_lv_obj_is_grid_item(obj)) lv_grid_item_refr_pos(obj);
|
||||||
|
|
||||||
if(lv_obj_get_grid(obj)) _lv_grid_full_refresh(obj);
|
if(lv_obj_get_grid(obj)) _lv_grid_full_refresh(obj);
|
||||||
|
|
||||||
|
if(_lv_obj_is_flex_item(obj)) _lv_flex_refresh(lv_obj_get_parent(obj));
|
||||||
|
if(lv_obj_get_flex_dir(obj)) _lv_flex_refresh(obj);
|
||||||
|
|
||||||
/*Reposition non grid objects on by one*/
|
/*Reposition non grid objects on by one*/
|
||||||
lv_obj_t * child;
|
lv_obj_t * child;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user