diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-18 13:21:42 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-18 13:21:42 +0300 |
commit | 7d7110c1dfe376334317983b4c2734ddb474ac8c (patch) | |
tree | d198c6bc21922639676c9284c3f9fe309f6d54ea /src/ui | |
parent | 95941a8fca886ba258716c535d51d0d68d075993 (diff) |
Fixed crash when hovered widget is destroyed
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/root.c | 8 | ||||
-rw-r--r-- | src/ui/widget.c | 7 | ||||
-rw-r--r-- | src/ui/window.c | 10 |
3 files changed, 20 insertions, 5 deletions
diff --git a/src/ui/root.c b/src/ui/root.c index 21bed366..b00fab28 100644 --- a/src/ui/root.c +++ b/src/ui/root.c | |||
@@ -278,6 +278,7 @@ void destroyPending_Root(iRoot *d) { | |||
278 | } | 278 | } |
279 | if (widget->flags & keepOnTop_WidgetFlag) { | 279 | if (widget->flags & keepOnTop_WidgetFlag) { |
280 | removeOne_PtrArray(d->onTop, widget); | 280 | removeOne_PtrArray(d->onTop, widget); |
281 | widget->flags &= ~keepOnTop_WidgetFlag; | ||
281 | } | 282 | } |
282 | iAssert(indexOf_PtrArray(d->onTop, widget) == iInvalidPos); | 283 | iAssert(indexOf_PtrArray(d->onTop, widget) == iInvalidPos); |
283 | if (widget->parent) { | 284 | if (widget->parent) { |
@@ -287,6 +288,13 @@ void destroyPending_Root(iRoot *d) { | |||
287 | iRelease(widget); | 288 | iRelease(widget); |
288 | remove_PtrSetIterator(&i); | 289 | remove_PtrSetIterator(&i); |
289 | } | 290 | } |
291 | #if 0 | ||
292 | printf("Root %p onTop (%zu):\n", d, size_PtrArray(d->onTop)); | ||
293 | iConstForEach(PtrArray, t, d->onTop) { | ||
294 | const iWidget *p = *t.value; | ||
295 | printf(" - %p {%s}\n", p, cstr_String(id_Widget(p))); | ||
296 | } | ||
297 | #endif | ||
290 | setCurrent_Root(oldRoot); | 298 | setCurrent_Root(oldRoot); |
291 | } | 299 | } |
292 | 300 | ||
diff --git a/src/ui/widget.c b/src/ui/widget.c index 184ce2a3..95a39470 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -156,6 +156,13 @@ void deinit_Widget(iWidget *d) { | |||
156 | if (d->flags & visualOffset_WidgetFlag) { | 156 | if (d->flags & visualOffset_WidgetFlag) { |
157 | removeTicker_App(visualOffsetAnimation_Widget_, d); | 157 | removeTicker_App(visualOffsetAnimation_Widget_, d); |
158 | } | 158 | } |
159 | iWindow *win = get_Window(); | ||
160 | if (win->lastHover == d) { | ||
161 | win->lastHover = NULL; | ||
162 | } | ||
163 | if (win->hover == d) { | ||
164 | win->hover = NULL; | ||
165 | } | ||
159 | widgetDestroyed_Touch(d); | 166 | widgetDestroyed_Touch(d); |
160 | } | 167 | } |
161 | 168 | ||
diff --git a/src/ui/window.c b/src/ui/window.c index 0dd248e6..5ac4f95e 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -1042,11 +1042,11 @@ void draw_Window(iWindow *d) { | |||
1042 | when the custom frame is being used. */ { | 1042 | when the custom frame is being used. */ { |
1043 | setCurrent_Root(d->roots[0]); | 1043 | setCurrent_Root(d->roots[0]); |
1044 | #if defined (iPlatformMobile) | 1044 | #if defined (iPlatformMobile) |
1045 | iColor back = get_Color(uiBackground_ColorId); | 1045 | iColor back = get_Color(uiBackground_ColorId); |
1046 | if (deviceType_App() == phone_AppDeviceType) { | 1046 | if (deviceType_App() == phone_AppDeviceType) { |
1047 | /* Page background extends to safe area, so fill it completely. */ | 1047 | /* Page background extends to safe area, so fill it completely. */ |
1048 | back = get_Color(tmBackground_ColorId); | 1048 | back = get_Color(tmBackground_ColorId); |
1049 | } | 1049 | } |
1050 | #else | 1050 | #else |
1051 | const iColor back = get_Color(gotFocus && d->place.snap != maximized_WindowSnap && | 1051 | const iColor back = get_Color(gotFocus && d->place.snap != maximized_WindowSnap && |
1052 | ~winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP | 1052 | ~winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP |