background: Fix reference counting in background XML loader
Commit b9e3603ba4
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
This commit is contained in:
parent
24faa84d05
commit
3491c6625c
1 changed files with 5 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue