[gtk/mcatanzaro/#2424] window: prepare for window destruction after gtk_window_close()



commit fe2370a5bad3602edfab028bf0fcd898b32b8556
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Feb 10 17:14:18 2020 -0600

    window: prepare for window destruction after gtk_window_close()
    
    Epiphany is doing something weird after calling gtk_window_close(),
    because by the time the callback executes, the window has no GdkWindow.
    Frankly, I don't know what's happening there, but we should probably not
    crash.
    
    Fixes #2424

 gtk/gtkwindow.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 7229518900..c8fb47668c 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1315,17 +1315,23 @@ send_delete_event (gpointer data)
 {
   GtkWidget *window = data;
   GtkWindowPrivate *priv = GTK_WINDOW (window)->priv;
+  GdkWindow *gdk_window;
 
-  GdkEvent *event;
+  priv->delete_event_handler = 0;
 
-  event = gdk_event_new (GDK_DELETE);
+  gdk_window = _gtk_widget_get_window (window);
+  if (gdk_window)
+    {
+      GdkEvent *event;
 
-  event->any.window = g_object_ref (_gtk_widget_get_window (window));
-  event->any.send_event = TRUE;
-  priv->delete_event_handler = 0;
+      event = gdk_event_new (GDK_DELETE);
+      event->any.window = g_object_ref (gdk_window);
+      event->any.send_event = TRUE;
+
+      gtk_main_do_event (event);
 
-  gtk_main_do_event (event);
-  gdk_event_free (event);
+      gdk_event_free (event);
+    }
 
   return G_SOURCE_REMOVE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]