mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-02 02:40:07 +02:00
gobject: clear "destroy_notify" during g_datalist_id_update_atomic()
During g_datalist_id_update_atomic(), we get "data" and "destroy_notify" pointers. The callback can then create, update or steal the data. It steals it by setting the `*data` to NULL. In that case, the "destroy_notify" has no more significance, because the old data was stolen (and won't be touched by g_datalist_id_update_atomic()) and the new data that we return is NULL (which means there is no data at all, and nothing to destroy). Still, to be clearer about that, clear the "destroy_notify" to NULL at a few places, where we steal the data. Note that there are other g_datalist_id_update_atomic() places that also steal the data but still don't reset the "destroy_notify". Those places are about the quark_closure_array (CArray) and quark_weak_notifies (WeakRefStack). For those keys, we never set any "destroy_notify". We relay on the fact that we take care of the data explicitly and we never set it. We also don't double check that it's really set to NULL, when we rightly expect it to be NULL already. At those places, it feels wrong to suddenly reset "destroy_notify" to NULL. This is different from the places where this patch clears the "destroy_notify". At those places, we (sometimes) do have a callback set, and it might be clearer to explicitly clear it.
This commit is contained in:
parent
1818d53034
commit
3ade8a93f3
@ -781,6 +781,7 @@ g_object_notify_queue_thaw_cb (gpointer *data,
|
||||
return NULL;
|
||||
|
||||
*data = NULL;
|
||||
*destroy_notify = NULL;
|
||||
return nqueue;
|
||||
}
|
||||
|
||||
@ -4579,6 +4580,7 @@ toggle_refs_unref_cb (gpointer *data,
|
||||
g_datalist_unset_flags (&trdata->object->qdata, OBJECT_HAS_TOGGLE_REF_FLAG);
|
||||
g_free (tstack);
|
||||
*data = NULL;
|
||||
*destroy_notify = NULL;
|
||||
}
|
||||
else if (i != tstack->n_toggle_refs)
|
||||
tstack->toggle_refs[i] = tstack->toggle_refs[tstack->n_toggle_refs];
|
||||
|
Loading…
x
Reference in New Issue
Block a user