mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-24 08:16:29 +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;
|
||||
|
||||
int32_t i = old_index;
|
||||
if(index < old_index)
|
||||
{
|
||||
while (i > index)
|
||||
{
|
||||
if(index < old_index) {
|
||||
while (i > index) {
|
||||
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--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (i < index)
|
||||
{
|
||||
else {
|
||||
while (i < index) {
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user