diff --git a/src/core.c b/src/core.c index 7a830a5..065dbac 100644 --- a/src/core.c +++ b/src/core.c @@ -170,7 +170,8 @@ MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget p } static void MwFreeWidget(MwWidget handle) { - int i; + int i; + MwWidget root = handle; MwDispatch(handle, destroy); @@ -178,6 +179,14 @@ static void MwFreeWidget(MwWidget handle) { MwFreeWidget(handle->children[i]); } + while(root->parent != NULL) root = root->parent; + for(i = 0; i < arrlen(root->tick_list); i++) { + if(handle == root->tick_list[i]) { + arrdel(root->tick_list, i); + i--; + } + } + free(handle->name); MwLLDestroy(handle->lowlevel); @@ -199,19 +208,9 @@ static void MwFreeWidget(MwWidget handle) { } void MwDestroyWidget(MwWidget handle) { - int i; - MwWidget root = handle; if(handle->parent != NULL) { arrput(handle->parent->destroy_queue, handle); } - - while(root->parent != NULL) root = root->parent; - for(i = 0; i < arrlen(root->tick_list); i++) { - if(handle == root->tick_list[i]) { - arrdel(root->tick_list, i); - i--; - } - } } void MwStep(MwWidget handle) {