[gnome-control-center] background: Fix a memory leak when monitoring directories



commit 5d16f81821f7c67781563b154f7ab2d1af9fd075
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Oct 2 16:32:17 2013 +0200

    background: Fix a memory leak when monitoring directories
    
    Destroy directory monitors on when the XML object is destroyed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709243

 panels/background/cc-background-xml.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/panels/background/cc-background-xml.c b/panels/background/cc-background-xml.c
index 868d19d..67a7beb 100644
--- a/panels/background/cc-background-xml.c
+++ b/panels/background/cc-background-xml.c
@@ -39,6 +39,7 @@ struct CcBackgroundXmlPrivate
   GHashTable  *wp_hash;
   GAsyncQueue *item_added_queue;
   guint        item_added_id;
+  GSList      *monitors; /* GSList of GFileMonitor */
 };
 
 #define CC_BACKGROUND_XML_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_BACKGROUND_XML, 
CcBackgroundXmlPrivate))
@@ -371,6 +372,8 @@ cc_background_xml_add_monitor (GFile      *directory,
   g_signal_connect (monitor, "changed",
                     G_CALLBACK (gnome_wp_file_changed),
                     data);
+
+  data->priv->monitors = g_slist_prepend (data->priv->monitors, monitor);
 }
 
 static void
@@ -626,6 +629,8 @@ cc_background_xml_finalize (GObject *object)
 
         g_return_if_fail (xml->priv != NULL);
 
+        g_slist_free_full (xml->priv->monitors, g_object_unref);
+
        g_clear_pointer (&xml->priv->wp_hash, g_hash_table_destroy);
        if (xml->priv->item_added_id != 0) {
                g_source_remove (xml->priv->item_added_id);


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