CSD close button result in CRITICAL when clicked
This has been going on for months.
Click any GtkHeaderBar close button. Make sure you click on the GtkImage inside the button. See critical.
(process:7880): Gtk-CRITICAL **: 08:34:42.954: _gtk_widget_captured_event: assertion 'WIDGET_REALIZED_FOR_EVENT (widget, event)' failed
This is happening because gtk_widget_unparent
calls gtk_widget_unrealize(widget)
. And in the clicked handler of the button, we destroy the entire toplevel window, so we unparent each widget and unrealize them. By the time the GtkImage is supposed to get the event, it's not realized anymore.
Much simpler test case:
#include <stdlib.h>
#include <gtk/gtk.h>
static void
clicked_cb (GtkButton *source,
gpointer user_data)
{
g_message (__FUNCTION__);
gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (source)));
}
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);
button = gtk_button_new_from_icon_name ("list-add-symbolic");
g_signal_connect (button, "clicked", G_CALLBACK (clicked_cb), NULL);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_main ();
return EXIT_SUCCESS;
}