mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 09:46:17 +01:00
gobject: Weaken an assertion in g_weak_ref_set()
When weak references are being cleaned up, it is possible for the `qdata` for both `quark_weak_locations` and `quark_weak_refs` to have been deallocated, so that `g_datalist_id_get_data()` returns `NULL` for both. This happens when `g_object_run_dispose()` is called for the target of a `GBinding`, and is not an error. See https://gitlab.gnome.org/GNOME/glib/-/issues/2676
This commit is contained in:
parent
8a43ae71c8
commit
94ba14d542
@ -5059,16 +5059,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user