[gtk+] gtkwindow: remove delete-event idle function on finalize



commit b91859a19aa21e33b4f85a656f72aa940738a3fa
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Thu Feb 6 17:25:55 2014 +0200

    gtkwindow: remove delete-event idle function on finalize
    
    Heavy duty can prevent this idle function from being called before
    the window is destroyed, so make sure that the source is removed
    when the window is finalized.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723771

 gtk/gtkwindow.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index d751837..0cb6305 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -156,6 +156,7 @@ struct _GtkWindowPrivate
   gchar   *wm_role;
 
   guint    keys_changed_handler;
+  guint    delete_event_handler;
 
   guint32  initial_timestamp;
 
@@ -1291,6 +1292,8 @@ static gboolean
 send_delete_event (gpointer data)
 {
   GtkWidget *window = data;
+  GtkWindowPrivate *priv = GTK_WINDOW (window)->priv;
+
   GdkEvent *event;
 
   event = gdk_event_new (GDK_DELETE);
@@ -1301,6 +1304,8 @@ send_delete_event (gpointer data)
   gtk_main_do_event (event);
   gdk_event_free (event);
 
+  priv->delete_event_handler = 0;
+
   return G_SOURCE_REMOVE;
 }
 
@@ -1322,7 +1327,7 @@ gtk_window_close (GtkWindow *window)
   if (!gtk_widget_get_realized (GTK_WIDGET (window)))
     return;
 
-  gdk_threads_add_idle (send_delete_event, window);
+  window->priv->delete_event_handler = gdk_threads_add_idle (send_delete_event, window);
 }
 
 static void
@@ -5273,6 +5278,12 @@ gtk_window_finalize (GObject *object)
       priv->keys_changed_handler = 0;
     }
 
+  if (priv->delete_event_handler)
+    {
+      g_source_remove (priv->delete_event_handler);
+      priv->delete_event_handler = 0;
+    }
+
   if (priv->screen)
     {
       g_signal_handlers_disconnect_by_func (priv->screen,
@@ -8573,7 +8584,8 @@ close_window_clicked (GtkMenuItem *menuitem,
 {
   GtkWindow *window = (GtkWindow *)user_data;
 
-  send_delete_event (window);
+  if (window->priv->delete_event_handler == 0)
+    send_delete_event (window);
 }
 
 static void


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