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



commit 732f8649bdf3c44c974b64b8aad692d700689d7c
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
    
    Conflicts:
        panels/background/cc-background-xml.c

 panels/background/cc-background-xml.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/panels/background/cc-background-xml.c b/panels/background/cc-background-xml.c
index 4d2a4f0..52b3154 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
@@ -630,6 +633,9 @@ cc_background_xml_finalize (GObject *object)
                g_hash_table_destroy (xml->priv->wp_hash);
                xml->priv->wp_hash = NULL;
        }
+
+        g_slist_free_full (xml->priv->monitors, g_object_unref);
+
        if (xml->priv->item_added_id != 0) {
                g_source_remove (xml->priv->item_added_id);
                xml->priv->item_added_id = 0;


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