Skip to content

gobject: Add function to check if GWeakRef is empty without changing it

Marco Trevisan requested to merge 3v1n0/glib:weak-ref-is-empty into main

GWeakRef can hold a destroyed pointer but we don't have a way to check if the weak reference is empty without affecting the wrapped object references, and this may lead to cause the object to be re-referenced when it's about to be destroyed, causing its toggle references to change during observation.

So add a function that allows to only safely check for weak references that contains an object that has been disposed, while when we return FALSE we can't guarantee that the object is still alive.

This can be still a relevant information when monitoring objects through weak references.


Ideally such function should never return real FALSE but instead an UNDEFINED value, but to do that we'd need to reverse the logic, and I'm not in love which such idea either.

Merge request reports