summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalev Lember <kalevlember@gmail.com>2013-10-04 21:28:45 +0200
committerKalev Lember <kalevlember@gmail.com>2013-10-07 10:42:30 +0200
commitd236f40b2f7f507839fbb81ec6db9a35c662aef3 (patch)
tree08803ca22dc8d0c4035140e6586588324fecf321
parent6db70d1489cc72a58ffe7f99e8d37c91dc44e899 (diff)
downloadgnome-control-center-d236f40b2f7f507839fbb81ec6db9a35c662aef3.tar.gz
background: Fix reference counting in background XML loader
Commit b9e3603ba4d6b494c0659cbc0196ef9f81fa6a60 added an unref to fix a memory leak, but it went to a wrong place -- in XML loader, all items are stored in a hash table that takes ownership of them, and destroyed when the hash table goes away. This commit fixes the reference counting in the XML loader and adds explicit g_object_ref / g_strdup when inserting values to the hash table to make the memory management more obvious. The following commit fixes the real leak. https://bugzilla.gnome.org/show_bug.cgi?id=709453
-rw-r--r--panels/background/cc-background-xml.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/panels/background/cc-background-xml.c b/panels/background/cc-background-xml.c
index 52b315439..bfd4ce842 100644
--- a/panels/background/cc-background-xml.c
+++ b/panels/background/cc-background-xml.c
@@ -311,13 +311,16 @@ cc_background_xml_load_xml_internal (CcBackgroundXml *xml,
}
g_object_set (G_OBJECT (item), "flags", flags, NULL);
- g_hash_table_insert (xml->priv->wp_hash, id, item);
- /* Don't free ID, we added it to the hash table */
+ g_hash_table_insert (xml->priv->wp_hash,
+ g_strdup (id),
+ g_object_ref (item));
if (in_thread)
emit_added_in_idle (xml, g_object_ref (item));
else
g_signal_emit (G_OBJECT (xml), signals[ADDED], 0, item);
+
g_object_unref (item);
+ g_free (id);
retval = TRUE;
}
}