comparison gtk4/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 d3d8a93124f1
children 3b3be9f7f452
comparison
equal deleted inserted replaced
2659:3a14d7fd4b99 2660:650f8b062317
562 char text[100]; 562 char text[100];
563 gint cid; 563 gint cid;
564 564
565 sprintf(text, "_dw_sigcid%d", counter); 565 sprintf(text, "_dw_sigcid%d", counter);
566 cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text)); 566 cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text));
567 g_signal_handler_disconnect(G_OBJECT(widget), cid); 567 if(cid > 0)
568 g_signal_handler_disconnect(G_OBJECT(widget), cid);
568 g_object_set_data(G_OBJECT(widget), text, NULL); 569 g_object_set_data(G_OBJECT(widget), text, NULL);
569 sprintf(text, "_dw_sigwindow%d", counter); 570 sprintf(text, "_dw_sigwindow%d", counter);
570 g_object_set_data(G_OBJECT(widget), text, NULL); 571 g_object_set_data(G_OBJECT(widget), text, NULL);
571 sprintf(text, "_dw_sigfunc%d", counter); 572 sprintf(text, "_dw_sigfunc%d", counter);
572 g_object_set_data(G_OBJECT(widget), text, NULL); 573 g_object_set_data(G_OBJECT(widget), text, NULL);
598 return counter - 1; 599 return counter - 1;
599 } 600 }
600 601
601 static void _dw_set_signal_handler_id(GObject *object, int counter, gint cid) 602 static void _dw_set_signal_handler_id(GObject *object, int counter, gint cid)
602 { 603 {
603 char text[100]; 604 if(cid > 0)
604 605 {
605 sprintf(text, "_dw_sigcid%d", counter); 606 char text[100];
606 g_object_set_data(object, text, GINT_TO_POINTER(cid)); 607
608 sprintf(text, "_dw_sigcid%d", counter);
609 g_object_set_data(object, text, GINT_TO_POINTER(cid));
610 }
611 else
612 dw_debug("WARNING: Dynamic Windows failed to connect signal.\n");
607 } 613 }
608 614
609 #ifdef USE_WEBKIT 615 #ifdef USE_WEBKIT
610 static void _dw_html_result_event(GObject *object, GAsyncResult *result, gpointer script_data) 616 static void _dw_html_result_event(GObject *object, GAsyncResult *result, gpointer script_data)
611 { 617 {