From: Aaron Erhardt Date: Sun, 16 Oct 2022 12:24:27 +0000 (+0200) Subject: Show a warning when a destroyed window is shown X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~423^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2fde4c9a5f99d48c1ba9cebeffa51de7a0f61a58;p=gtk4.git Show a warning when a destroyed window is shown Showing a destroyed window might cause an application to behave in an unexpected manner. For example, showing a dialog after it has been closed by the user might cause the application to freeze. The warning will help developers to track down the issue. Signed-off-by: Aaron Erhardt --- diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 21e0ac3036..8da622543f 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -3811,6 +3811,10 @@ gtk_window_show (GtkWidget *widget) GtkWindow *window = GTK_WINDOW (widget); GtkWindowPrivate *priv = gtk_window_get_instance_private (window); + guint i; + if (!g_list_store_find (toplevel_list, window, &i)) + g_warning("The window is shown after it has been destroyed. This will leave the window in an inconsistent state."); + _gtk_widget_set_visible_flag (widget, TRUE); gtk_css_node_validate (gtk_widget_get_css_node (widget));