Skip to content

Commit 0bd0e31

Browse files
committed
Refactor GUI root node creation.
1 parent a80d776 commit 0bd0e31

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

plugins/gui/gui.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,16 @@ ctr_object* ctr_gui_xml_at_set(ctr_object* myself, ctr_argument* argumentList) {
355355
lv_obj_t* root = lv_screen_active();
356356
char* xml = ctr_heap_allocate_cstring(argumentList->object);
357357
char* name = ctr_heap_allocate_cstring(ctr_internal_cast2string(argumentList->next->object));
358-
uint32_t id = ctr_tonum(argumentList->next->next->object);
359-
lv_obj_t* child = lv_obj_get_child_by_id(root, &id);
358+
uint32_t id;
359+
lv_obj_t* child = root;
360360
if (CtrEventHandler == NULL) {
361361
CtrEventHandler = lv_obj_add_event_cb(root, &ctr_gui_internal_event_handler, LV_EVENT_ALL, NULL);
362362
}
363-
if (!child) child = root;
363+
if (argumentList->next->next->object != CtrStdNil) {
364+
id = ctr_tonum(argumentList->next->next->object);
365+
child = lv_obj_get_child_by_id(root, &id);
366+
if (!child) child = root;
367+
}
364368
uint32_t n = lv_obj_get_child_count(child);
365369
for(int i = 0; i < n; i++) {
366370
lv_obj_t* old = lv_obj_get_child(child, i);

0 commit comments

Comments
 (0)