diff gtk3/dw.c @ 2660:650f8b062317

GTK: Check the Connection ID is positive non-zero before removing. The connection ID will be zero under two conditions: 1) The GTK signal handler failed to be created or 2) The Dynamic Windows handler uses an existing GTK handler Therefore we don't want to ASSERT when removing a DW handler when it uses an existing GTK handler. So check and warn if the CID is invalid at creation time, and skip invalid CIDs at removal time. Thanks Mark for pointing out this misbehavior.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 02 Oct 2021 19:30:39 +0000
parents 401a3b9f21ba
children 3b3be9f7f452
line wrap: on
line diff
--- a/gtk3/dw.c	Fri Sep 24 21:50:17 2021 +0000
+++ b/gtk3/dw.c	Sat Oct 02 19:30:39 2021 +0000
@@ -1166,7 +1166,8 @@
 
    sprintf(text, "_dw_sigcid%d", counter);
    cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text));
-   g_signal_handler_disconnect(G_OBJECT(widget), cid);
+   if(cid > 0)
+      g_signal_handler_disconnect(G_OBJECT(widget), cid);
    g_object_set_data(G_OBJECT(widget), text, NULL);
    sprintf(text, "_dw_sigwindow%d", counter);
    g_object_set_data(G_OBJECT(widget), text, NULL);
@@ -1202,10 +1203,15 @@
 
 static void _dw_set_signal_handler_id(GtkWidget *widget, int counter, gint cid)
 {
-   char text[100];
-
-   sprintf(text, "_dw_sigcid%d", counter);
-   g_object_set_data(G_OBJECT(widget), text, GINT_TO_POINTER(cid));
+   if(cid > 0)
+   {
+      char text[100];
+
+      sprintf(text, "_dw_sigcid%d", counter);
+      g_object_set_data(G_OBJECT(widget), text, GINT_TO_POINTER(cid));
+   }
+   else
+      dw_debug("WARNING: Dynamic Windows failed to connect signal.\n");
 }
 
 static void _dw_html_result_event(GObject *object, GAsyncResult *result, gpointer script_data)