Mercurial > dwindows
changeset 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 | 3a14d7fd4b99 |
children | 2b37d9b025cf |
files | gtk/dw.c gtk3/dw.c gtk4/dw.c |
diffstat | 3 files changed, 33 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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)
--- 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