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



commit 536bd2a535fe6a72f52ad2b2c4558f5ce4ad2cdf
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.
    Probably the window has been manually destroyed before the callback
    executes. Guard against that.
    
    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]