Merge branch '2672-dataset-tests-and-fixes' into 'main'

gdataset: Preserve destruction order

Closes #2672 and #2676

See merge request GNOME/glib!2776
This commit is contained in:
Philip Withnall
2022-07-07 11:52:19 +00:00
4 changed files with 152 additions and 16 deletions

View File

@@ -5049,16 +5049,22 @@ g_weak_ref_set (GWeakRef *weak_ref,
/* Remove the weak ref from the old object */
if (old_object != NULL)
{
gboolean in_weak_refs_notify;
weak_locations = g_datalist_id_get_data (&old_object->qdata, quark_weak_locations);
in_weak_refs_notify = g_datalist_id_get_data (&old_object->qdata, quark_weak_refs) == NULL;
/* for it to point to an object, the object must have had it added once */
g_assert (weak_locations != NULL);
g_assert (weak_locations != NULL || in_weak_refs_notify);
*weak_locations = g_slist_remove (*weak_locations, weak_ref);
if (!*weak_locations)
if (weak_locations != NULL)
{
weak_locations_free_unlocked (weak_locations);
g_datalist_id_remove_no_notify (&old_object->qdata, quark_weak_locations);
*weak_locations = g_slist_remove (*weak_locations, weak_ref);
if (!*weak_locations)
{
weak_locations_free_unlocked (weak_locations);
g_datalist_id_remove_no_notify (&old_object->qdata, quark_weak_locations);
}
}
}