mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-29 11:00:02 +01:00
It can happen that a GWeakRef is added to an object while it's disposing (or even during finalizing) and this may happen in a thread that (weak) references an object while the disposal isn't completed yet or when using toggle references and switching to GWeakRef on notification (as the API suggests). In such scenario the weak locations are not cleaned up when the object is finalized, and will point to a free'd area. So, during finalization and when we're sure that the object will be destroyed for sure, check again if there are new weak locations and unset them if any as part of the qdata destruction. Do this adding a new utility function so that we can avoid duplicating code to free the weak locations. Added various tests simulating this case. Fixes: #2390