[gnome-control-center/gnome-3-8] background: Fix reference counting in background XML loader
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-8] background: Fix reference counting in background XML loader
- Date: Mon, 7 Oct 2013 10:57:50 +0000 (UTC)
commit d236f40b2f7f507839fbb81ec6db9a35c662aef3
Author: Kalev Lember <kalevlember gmail com>
Date: Fri Oct 4 21:28:45 2013 +0200
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
panels/background/cc-background-xml.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/panels/background/cc-background-xml.c b/panels/background/cc-background-xml.c
index 52b3154..bfd4ce8 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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]