mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 16:58:33 +08:00
fix(obj) in lv_obj_move_to_index() do not send LV_EVENT_CHILD_CHANGED on all changed child
The events will see half-ready child list and might crash fixes #2541
This commit is contained in:
+6
-11
@@ -210,26 +210,21 @@ void lv_obj_move_to_index(lv_obj_t * obj, int32_t index)
|
|||||||
if(index == old_index) return;
|
if(index == old_index) return;
|
||||||
|
|
||||||
int32_t i = old_index;
|
int32_t i = old_index;
|
||||||
if(index < old_index)
|
if(index < old_index) {
|
||||||
{
|
while (i > index) {
|
||||||
while (i > index)
|
|
||||||
{
|
|
||||||
parent->spec_attr->children[i] = parent->spec_attr->children[i - 1];
|
parent->spec_attr->children[i] = parent->spec_attr->children[i - 1];
|
||||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, parent->spec_attr->children[i]);
|
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
while (i < index) {
|
||||||
while (i < index)
|
|
||||||
{
|
|
||||||
parent->spec_attr->children[i] = parent->spec_attr->children[i + 1];
|
parent->spec_attr->children[i] = parent->spec_attr->children[i + 1];
|
||||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, parent->spec_attr->children[i]);
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parent->spec_attr->children[index] = obj;
|
parent->spec_attr->children[index] = obj;
|
||||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
|
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, NULL);
|
||||||
lv_obj_invalidate(parent);
|
lv_obj_invalidate(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user