From e45c8579cc1dbe6e3d358f03e2e732ff64762121 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 31 May 2005 19:03:59 +0000 Subject: [PATCH] Correctly manage our reference on document. Finally the reload huge leak 2005-05-31 Marco Pesenti Gritti * shell/ev-sidebar-links.c: (ev_sidebar_links_dispose), (ev_sidebar_links_class_init), (ev_sidebar_links_set_document): Correctly manage our reference on document. Finally the reload huge leak is gone... --- ChangeLog | 8 ++++++ shell/ev-sidebar-links.c | 53 ++++++++++++++-------------------------- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b240a2f..693fe22e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-05-31 Marco Pesenti Gritti + + * shell/ev-sidebar-links.c: (ev_sidebar_links_dispose), + (ev_sidebar_links_class_init), (ev_sidebar_links_set_document): + + Correctly manage our reference on document. Finally the reload + huge leak is gone... + 2005-05-31 Marco Pesenti Gritti * ps/ps-document.c: (ps_document_dispose): diff --git a/shell/ev-sidebar-links.c b/shell/ev-sidebar-links.c index fdd48441..1d73822b 100644 --- a/shell/ev-sidebar-links.c +++ b/shell/ev-sidebar-links.c @@ -68,7 +68,6 @@ static void row_activated_callback (GtkTreeView *treeview, GtkTreeViewColumn *arg2, gpointer user_data); static void ev_sidebar_links_page_iface_init (EvSidebarPageIface *iface); -static void ev_sidebar_links_clear_document (EvSidebarLinks *sidebar_links); static void ev_sidebar_links_set_document (EvSidebarPage *sidebar_page, EvDocument *document); static gboolean ev_sidebar_links_support_document (EvSidebarPage *sidebar_page, @@ -87,15 +86,6 @@ G_DEFINE_TYPE_EXTENDED (EvSidebarLinks, #define EV_SIDEBAR_LINKS_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_LINKS, EvSidebarLinksPrivate)) - -static void -ev_sidebar_links_destroy (GtkObject *object) -{ - EvSidebarLinks *ev_sidebar_links = (EvSidebarLinks *) object; - - ev_sidebar_links_clear_document (ev_sidebar_links); -} - static void ev_sidebar_links_set_property (GObject *object, guint prop_id, @@ -142,20 +132,30 @@ ev_sidebar_links_get_property (GObject *object, } } +static void +ev_sidebar_links_dispose (GObject *object) +{ + EvSidebarLinks *sidebar = EV_SIDEBAR_LINKS (object); + + if (sidebar->priv->document) { + g_object_unref (sidebar->priv->document); + sidebar->priv->document = NULL; + sidebar->priv->page_cache = NULL; + } + + G_OBJECT_CLASS (ev_sidebar_links_parent_class)->dispose (object); +} static void ev_sidebar_links_class_init (EvSidebarLinksClass *ev_sidebar_links_class) { GObjectClass *g_object_class; - GtkObjectClass *gtk_object_class; g_object_class = G_OBJECT_CLASS (ev_sidebar_links_class); - gtk_object_class = GTK_OBJECT_CLASS (ev_sidebar_links_class); g_object_class->set_property = ev_sidebar_links_set_property; g_object_class->get_property = ev_sidebar_links_get_property; - - gtk_object_class->destroy = ev_sidebar_links_destroy; + g_object_class->dispose = ev_sidebar_links_dispose; g_object_class_install_property (g_object_class, PROP_MODEL, @@ -434,24 +434,6 @@ ev_sidebar_links_new (void) return ev_sidebar_links; } -static void -ev_sidebar_links_clear_document (EvSidebarLinks *sidebar_links) -{ - EvSidebarLinksPrivate *priv; - - g_return_if_fail (EV_IS_SIDEBAR_LINKS (sidebar_links)); - - priv = sidebar_links->priv; - - if (priv->document) { - g_object_unref (priv->document); - priv->document = NULL; - priv->page_cache = NULL; - } - - gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), NULL); -} - static gboolean update_page_callback_foreach (GtkTreeModel *model, GtkTreePath *path, @@ -582,9 +564,12 @@ ev_sidebar_links_set_document (EvSidebarPage *sidebar_page, priv = sidebar_links->priv; - g_object_ref (document); + if (priv->document) { + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), NULL); + g_object_unref (priv->document); + } - priv->document = document; + priv->document = g_object_ref (document); priv->page_cache = ev_document_get_page_cache (document); priv->job = ev_job_links_new (document); -- 2.43.5