Mercurial > dwindows
comparison gtk/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 | a1340a70923d |
children | 1f2c4f7aca4b |
comparison
equal
deleted
inserted
replaced
2659:3a14d7fd4b99 | 2660:650f8b062317 |
---|---|
1210 char text[101] = {0}; | 1210 char text[101] = {0}; |
1211 gint cid; | 1211 gint cid; |
1212 | 1212 |
1213 snprintf(text, 100, "_dw_sigcid%d", counter); | 1213 snprintf(text, 100, "_dw_sigcid%d", counter); |
1214 cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text)); | 1214 cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text)); |
1215 gtk_signal_disconnect(GTK_OBJECT(widget), cid); | 1215 if(cid > 0) |
1216 gtk_signal_disconnect(GTK_OBJECT(widget), cid); | |
1216 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); | 1217 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); |
1217 snprintf(text, 100, "_dw_sigwindow%d", counter); | 1218 snprintf(text, 100, "_dw_sigwindow%d", counter); |
1218 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); | 1219 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); |
1219 snprintf(text, 100, "_dw_sigfunc%d", counter); | 1220 snprintf(text, 100, "_dw_sigfunc%d", counter); |
1220 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); | 1221 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); |
1244 return counter - 1; | 1245 return counter - 1; |
1245 } | 1246 } |
1246 | 1247 |
1247 static void _dw_set_signal_handler_id(GtkWidget *widget, int counter, gint cid) | 1248 static void _dw_set_signal_handler_id(GtkWidget *widget, int counter, gint cid) |
1248 { | 1249 { |
1249 char text[101] = {0}; | 1250 if(cid > 0) |
1250 | 1251 { |
1251 snprintf(text, 100, "_dw_sigcid%d", counter); | 1252 char text[101] = {0}; |
1252 gtk_object_set_data(GTK_OBJECT(widget), text, GINT_TO_POINTER(cid)); | 1253 |
1254 snprintf(text, 100, "_dw_sigcid%d", counter); | |
1255 gtk_object_set_data(GTK_OBJECT(widget), text, GINT_TO_POINTER(cid)); | |
1256 } | |
1257 else | |
1258 dw_debug("WARNING: Dynamic Windows failed to connect signal.\n"); | |
1253 } | 1259 } |
1254 | 1260 |
1255 #ifdef USE_WEBKIT | 1261 #ifdef USE_WEBKIT |
1256 static void _dw_html_changed_event(WebKitWebView *web_view, WebKitWebFrame *frame, gpointer data) | 1262 static void _dw_html_changed_event(WebKitWebView *web_view, WebKitWebFrame *frame, gpointer data) |
1257 { | 1263 { |