When adding a Geometry Nodes Tree or unlinking a Geometry Nodes Tree to a Modifier, the User count always stays above 0. (id-us >= 1)
(see: https://developer.blender.org/T84624
for more detail)
This seems to be caused by two things
- On all Node Trees/Node Groups the function is id_us_ensure_real() is called.
this sets LIB_TAG_EXTRAUSER and LIB_TAG_EXTRAUSER_SET flags which than cause that id_min() can not set the user count to 0 even after removing the last user. My solution here is to not call id_us_ensure_real() for Geometry Node Type, since it seems not working right here.
But. I don't fully understand why it is needed and working for other node types. A more mighty wizard is needed to clarify how this works.
- RNA update function seems to be called only after assignment and so only on the newly assigned value not the old one.. So, when we add a new node_group to the Modifier,
we need to store the old value, assign the new value and than decrement the user count on the old value manualy. Since the interface button calls a Python function to add a new Node Group to the Modifier I added a new rna function called node_group_new() for modifiers, to handle this.