Lagrange [work/v1.7]

Fixed crash when hovered widget is destroyed

=> 7d7110c1dfe376334317983b4c2734ddb474ac8c

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) {
         }
         if (widget->flags & keepOnTop_WidgetFlag) {
             removeOne_PtrArray(d->onTop, widget);
+            widget->flags &= ~keepOnTop_WidgetFlag;
         }
         iAssert(indexOf_PtrArray(d->onTop, widget) == iInvalidPos);
         if (widget->parent) {
@@ -287,6 +288,13 @@ void destroyPending_Root(iRoot *d) {
         iRelease(widget);
         remove_PtrSetIterator(&i);
     }
+#if 0
+    printf("Root %p onTop (%zu):\n", d, size_PtrArray(d->onTop));
+    iConstForEach(PtrArray, t, d->onTop) {
+        const iWidget *p = *t.value;
+        printf(" - %p {%s}\n", p, cstr_String(id_Widget(p)));
+    }
+#endif
     setCurrent_Root(oldRoot);
 }
 
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) {
     if (d->flags & visualOffset_WidgetFlag) {
         removeTicker_App(visualOffsetAnimation_Widget_, d);
     }
+    iWindow *win = get_Window();
+    if (win->lastHover == d) {
+        win->lastHover = NULL;
+    }
+    if (win->hover == d) {
+        win->hover = NULL;
+    }
     widgetDestroyed_Touch(d);
 }
 
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) {
        when the custom frame is being used. */ {
         setCurrent_Root(d->roots[0]);
 #if defined (iPlatformMobile)
-       iColor back = get_Color(uiBackground_ColorId);
-       if (deviceType_App() == phone_AppDeviceType) {
-           /* Page background extends to safe area, so fill it completely. */
-           back = get_Color(tmBackground_ColorId);
-       }
+        iColor back = get_Color(uiBackground_ColorId);
+        if (deviceType_App() == phone_AppDeviceType) {
+            /* Page background extends to safe area, so fill it completely. */
+            back = get_Color(tmBackground_ColorId);
+        }
 #else
         const iColor back = get_Color(gotFocus && d->place.snap != maximized_WindowSnap &&
                                               ~winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.7/cdiff/7d7110c1dfe376334317983b4c2734ddb474ac8c
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
58.695747 milliseconds
Gemini-to-HTML Time
0.323359 milliseconds

This content has been proxied by September (ba2dc).