Skip to content

Commit 78c7a5b

Browse files
committed
Properly remove child hierarchy in tree before adding new nodes.
1 parent c0ae428 commit 78c7a5b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

plugins/gui/gui.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,8 @@ ctr_object* ctr_gui_xml_at_set(ctr_object* myself, ctr_argument* argumentList) {
367367
if (!child) child = root;
368368
}
369369
uint32_t n = lv_obj_get_child_count(child);
370-
for(int i = 0; i < n; i++) {
371-
lv_obj_t* old = lv_obj_get_child(child, i);
372-
lv_obj_delete(old);
373-
}
370+
lv_obj_t* old;
371+
while (old = lv_obj_get_child(child, -1)) lv_obj_delete(old);
374372
lv_xml_component_register_from_data(name, xml);
375373
lv_xml_create(child, name, NULL);
376374
ctr_heap_free(xml);

0 commit comments

Comments
 (0)