fix ui_show reference counting, when the window is already visible (GTK) newapi

Wed, 27 Nov 2024 18:54:00 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 27 Nov 2024 18:54:00 +0100
branch
newapi
changeset 396
4cb216085479
parent 395
b8277deb75b8
child 397
6d4adf6fba1f

fix ui_show reference counting, when the window is already visible (GTK)

ui/gtk/toolkit.c file | annotate | diff | comparison | revisions
--- a/ui/gtk/toolkit.c	Wed Nov 27 18:46:45 2024 +0100
+++ b/ui/gtk/toolkit.c	Wed Nov 27 18:54:00 2024 +0100
@@ -158,13 +158,18 @@
 #endif
 
 void ui_show(UiObject *obj) {
+    gboolean visible = gtk_widget_is_visible(obj->widget);
+    
     uic_check_group_widgets(obj->ctx);
 #if GTK_MAJOR_VERSION >= 4
     gtk_window_present(GTK_WINDOW(obj->widget));
 #elif GTK_MAJOR_VERSION <= 3
     gtk_widget_show_all(obj->widget);
 #endif
-    obj->ref++;
+    
+    if(!visible) {
+        obj->ref++;
+    }
 }
 
 void ui_close(UiObject *obj) {

mercurial