From e60ddfc9afc26b75cf9aa31c1a8c3b7e390a4ac7 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 10 Mar 2021 10:01:05 +0200 Subject: Widget: Crash if moving widget is deleted --- src/ui/widget.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/ui/widget.c') diff --git a/src/ui/widget.c b/src/ui/widget.c index ec229b86..b31b3c08 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c @@ -91,6 +91,17 @@ void init_Widget(iWidget *d) { iZap(d->padding); } +static void visualOffsetAnimation_Widget_(void *ptr) { + iWidget *d = ptr; + postRefresh_App(); + if (!isFinished_Anim(&d->visualOffset)) { + addTicker_App(visualOffsetAnimation_Widget_, ptr); + } + else { + setFlags_Widget(d, visualOffset_WidgetFlag, iFalse); + } +} + void deinit_Widget(iWidget *d) { releaseChildren_Widget(d); #if !defined (NDEBUG) @@ -101,6 +112,9 @@ void deinit_Widget(iWidget *d) { if (d->flags & keepOnTop_WidgetFlag) { removeAll_PtrArray(onTop_RootData_(), d); } + if (d->flags & visualOffset_WidgetFlag) { + removeTicker_App(visualOffsetAnimation_Widget_, d); + } widgetDestroyed_Touch(d); } @@ -191,17 +205,6 @@ void setPadding_Widget(iWidget *d, int left, int top, int right, int bottom) { d->padding[3] = bottom; } -static void visualOffsetAnimation_Widget_(void *ptr) { - iWidget *d = ptr; - postRefresh_App(); - if (!isFinished_Anim(&d->visualOffset)) { - addTicker_App(visualOffsetAnimation_Widget_, ptr); - } - else { - setFlags_Widget(d, visualOffset_WidgetFlag, iFalse); - } -} - void setVisualOffset_Widget(iWidget *d, int value, uint32_t span, int animFlags) { setFlags_Widget(d, visualOffset_WidgetFlag, iTrue); if (span == 0) { -- cgit v1.2.3