Skip to content

Commit 89faa5d

Browse files
committed
fix(gui): the unlink event is triggered repeatedly
1 parent 7abc901 commit 89faa5d

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/gui/widget_base.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,10 @@ void LCUIWidget_ClearTrash(void)
121121

122122
static void Widget_AddToTrash(LCUI_Widget w)
123123
{
124-
LCUI_WidgetEventRec e = { 0 };
125-
e.type = LCUI_WEVENT_UNLINK;
126124
w->state = LCUI_WSTATE_DELETED;
127-
Widget_TriggerEvent(w, &e, NULL);
128-
if (!w->parent) {
125+
if (Widget_Unlink(w) != 0) {
129126
return;
130127
}
131-
Widget_Unlink(w);
132128
LinkedList_AppendNode(&LCUIWidget.trash, &w->node);
133129
Widget_PostSurfaceEvent(w, LCUI_WEVENT_UNLINK, TRUE);
134130
}
@@ -393,15 +389,14 @@ void Widget_ExecDestroy(LCUI_Widget widget)
393389
void Widget_Destroy(LCUI_Widget w)
394390
{
395391
LCUI_Widget root = w;
392+
393+
assert(w->state != LCUI_WSTATE_DELETED);
396394
while (root->parent) {
397395
root = root->parent;
398396
}
399397
/* If this widget is not mounted in the root widget tree */
400398
if (root != LCUIWidget.root) {
401-
LCUI_WidgetEventRec e = { 0 };
402-
e.type = LCUI_WEVENT_UNLINK;
403399
w->state = LCUI_WSTATE_DELETED;
404-
Widget_TriggerEvent(w, &e, NULL);
405400
Widget_ExecDestroy(w);
406401
return;
407402
}

0 commit comments

Comments
 (0)