Mercurial > dwindows
comparison 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 |
comparison
equal
deleted
inserted
replaced
2659:3a14d7fd4b99 | 2660:650f8b062317 |
---|---|
1164 char text[100]; | 1164 char text[100]; |
1165 gint cid; | 1165 gint cid; |
1166 | 1166 |
1167 sprintf(text, "_dw_sigcid%d", counter); | 1167 sprintf(text, "_dw_sigcid%d", counter); |
1168 cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text)); | 1168 cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text)); |
1169 g_signal_handler_disconnect(G_OBJECT(widget), cid); | 1169 if(cid > 0) |
1170 g_signal_handler_disconnect(G_OBJECT(widget), cid); | |
1170 g_object_set_data(G_OBJECT(widget), text, NULL); | 1171 g_object_set_data(G_OBJECT(widget), text, NULL); |
1171 sprintf(text, "_dw_sigwindow%d", counter); | 1172 sprintf(text, "_dw_sigwindow%d", counter); |
1172 g_object_set_data(G_OBJECT(widget), text, NULL); | 1173 g_object_set_data(G_OBJECT(widget), text, NULL); |
1173 sprintf(text, "_dw_sigfunc%d", counter); | 1174 sprintf(text, "_dw_sigfunc%d", counter); |
1174 g_object_set_data(G_OBJECT(widget), text, NULL); | 1175 g_object_set_data(G_OBJECT(widget), text, NULL); |
1200 return counter - 1; | 1201 return counter - 1; |
1201 } | 1202 } |
1202 | 1203 |
1203 static void _dw_set_signal_handler_id(GtkWidget *widget, int counter, gint cid) | 1204 static void _dw_set_signal_handler_id(GtkWidget *widget, int counter, gint cid) |
1204 { | 1205 { |
1205 char text[100]; | 1206 if(cid > 0) |
1206 | 1207 { |
1207 sprintf(text, "_dw_sigcid%d", counter); | 1208 char text[100]; |
1208 g_object_set_data(G_OBJECT(widget), text, GINT_TO_POINTER(cid)); | 1209 |
1210 sprintf(text, "_dw_sigcid%d", counter); | |
1211 g_object_set_data(G_OBJECT(widget), text, GINT_TO_POINTER(cid)); | |
1212 } | |
1213 else | |
1214 dw_debug("WARNING: Dynamic Windows failed to connect signal.\n"); | |
1209 } | 1215 } |
1210 | 1216 |
1211 static void _dw_html_result_event(GObject *object, GAsyncResult *result, gpointer script_data) | 1217 static void _dw_html_result_event(GObject *object, GAsyncResult *result, gpointer script_data) |
1212 { | 1218 { |
1213 #if USE_WEBKIT2 | 1219 #if USE_WEBKIT2 |