# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1633203039 0 # Node ID 650f8b062317b91cea1c13109a69afc4092a417f # Parent 3a14d7fd4b992bcd6d3f20a74cb9e46d50a20afe 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. diff -r 3a14d7fd4b99 -r 650f8b062317 gtk/dw.c --- a/gtk/dw.c Fri Sep 24 21:50:17 2021 +0000 +++ b/gtk/dw.c Sat Oct 02 19:30:39 2021 +0000 @@ -1212,7 +1212,8 @@ snprintf(text, 100, "_dw_sigcid%d", counter); cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text)); - gtk_signal_disconnect(GTK_OBJECT(widget), cid); + if(cid > 0) + gtk_signal_disconnect(GTK_OBJECT(widget), cid); gtk_object_set_data(GTK_OBJECT(widget), text, NULL); snprintf(text, 100, "_dw_sigwindow%d", counter); gtk_object_set_data(GTK_OBJECT(widget), text, NULL); @@ -1246,10 +1247,15 @@ static void _dw_set_signal_handler_id(GtkWidget *widget, int counter, gint cid) { - char text[101] = {0}; - - snprintf(text, 100, "_dw_sigcid%d", counter); - gtk_object_set_data(GTK_OBJECT(widget), text, GINT_TO_POINTER(cid)); + if(cid > 0) + { + char text[101] = {0}; + + snprintf(text, 100, "_dw_sigcid%d", counter); + gtk_object_set_data(GTK_OBJECT(widget), text, GINT_TO_POINTER(cid)); + } + else + dw_debug("WARNING: Dynamic Windows failed to connect signal.\n"); } #ifdef USE_WEBKIT diff -r 3a14d7fd4b99 -r 650f8b062317 gtk3/dw.c --- 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) diff -r 3a14d7fd4b99 -r 650f8b062317 gtk4/dw.c --- a/gtk4/dw.c Fri Sep 24 21:50:17 2021 +0000 +++ b/gtk4/dw.c Sat Oct 02 19:30:39 2021 +0000 @@ -564,7 +564,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); @@ -600,10 +601,15 @@ static void _dw_set_signal_handler_id(GObject *object, int counter, gint cid) { - char text[100]; - - sprintf(text, "_dw_sigcid%d", counter); - g_object_set_data(object, text, GINT_TO_POINTER(cid)); + if(cid > 0) + { + char text[100]; + + sprintf(text, "_dw_sigcid%d", counter); + g_object_set_data(object, text, GINT_TO_POINTER(cid)); + } + else + dw_debug("WARNING: Dynamic Windows failed to connect signal.\n"); } #ifdef USE_WEBKIT