[gtk/nbpage: 12/21] notebook: Fix up ref counting



commit c1ad7217b576d439be699d550e9b1c66802e6ba0
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Feb 20 23:02:39 2019 -0500

    notebook: Fix up ref counting
    
    We need to keep a ref to the page objects.

 gtk/gtknotebook.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index c9ea3bf72b..34ee81199c 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -4216,7 +4216,7 @@ gtk_notebook_insert_notebook_page (GtkNotebook *notebook,
   if ((position < 0) || (position > nchildren))
     position = nchildren;
 
-  priv->children = g_list_insert (priv->children, page, position);
+  priv->children = g_list_insert (priv->children, g_object_ref (page), position);
 
   if (position < nchildren)
     sibling = GTK_NOTEBOOK_PAGE_FROM_LIST (g_list_nth (priv->children, position))->tab_widget;
@@ -4305,6 +4305,7 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
                                gint         position)
 {
   GtkNotebookPage *page;
+  int ret;
 
   page = g_object_new (GTK_TYPE_NOTEBOOK_PAGE,
                        "child", child,
@@ -4312,7 +4313,11 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
                        "menu", menu_label,
                        NULL);
 
-  return gtk_notebook_insert_notebook_page (notebook, page, position);
+  ret = gtk_notebook_insert_notebook_page (notebook, page, position);
+
+  g_object_unref (page);
+
+  return ret;
 }
 
 static gboolean


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