[gtk+] Unregister the popover before destroying it



commit c28784524016b2a8eac18d5046ebc8cdaca7f9b0
Author: William Jon McCann <william jon mccann gmail com>
Date:   Fri Feb 21 13:43:55 2014 -0500

    Unregister the popover before destroying it
    
    Fixes a leak of the registered_windows list in GtkWidget.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=554618

 gtk/gtkwindow.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 7d37b6f..befca5a 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1338,8 +1338,18 @@ popover_destroy (GtkWindowPopover *popover)
       popover->unmap_id = 0;
     }
 
-  if (popover->widget && gtk_widget_get_parent (popover->widget))
-    gtk_widget_unparent (popover->widget);
+  if (popover->widget)
+    {
+      GtkWidget *parent;
+
+      parent = gtk_widget_get_parent (popover->widget);
+
+      if (parent)
+        {
+          gtk_widget_unregister_window (parent, popover->window);
+          gtk_widget_unparent (popover->widget);
+        }
+    }
 
   if (popover->window)
     gdk_window_destroy (popover->window);
@@ -6252,8 +6262,10 @@ gtk_window_realize (GtkWidget *widget)
 
 static void
 popover_unrealize (GtkWidget        *widget,
-                   GtkWindowPopover *popover)
+                   GtkWindowPopover *popover,
+                   GtkWindow        *window)
 {
+  gtk_widget_unregister_window (GTK_WIDGET (window), popover->window);
   gtk_widget_unrealize (popover->widget);
   gdk_window_destroy (popover->window);
   popover->window = NULL;
@@ -6316,7 +6328,7 @@ gtk_window_unrealize (GtkWidget *widget)
     {
       GtkWindowPopover *popover = link->data;
       link = link->next;
-      popover_unrealize (popover->widget, popover);
+      popover_unrealize (popover->widget, popover, window);
     }
 
   GTK_WIDGET_CLASS (gtk_window_parent_class)->unrealize (widget);


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