Bastien Montagne f4ae983dfb RNA: Improve handling of ID refcounting by Pointer properties.
This commit works on two related issues:
1. It is too easy to forget to handle ID refcounting in custom RNA setters.
2. It is not possible to fully force RNA refcounting ON or OFF for some
   properties.

Issue 1. has bit us several times recently (e.g. in animation or
compositor areas, see latest fix blender/blender!143577).

This commit addresses it by adding some debug-only checks around the
call to `PointerPropertyRNA::set()` in `RNA_property_pointer_set()`,
that validates that usercount of both previously and newly assigned IDs
matches expected (changes of) values.

While not ideal, this should make it way easier for developers to catch
that issue in the future.

The second issue was discovered while working on the first, leading to
e.g. questionable work-arounds like the `rna_DriverTarget_id_set`
setter, only defined to by-pass the automatically assigned
`PROP_ID_USERCOUNT` flag (and related automatic refcounting of the
default setter code).

It is addressed by adding an internal `PROP_INTERN_PTR_ID_REFCOUNT_FORCED`
flag, which keeps track of calls to
`RNA_def_property_flag`/`RNA_def_property_clear_flag` which explicitely
sets or clears the `PROP_ID_USERCOUNT` flag, and prevents automatic
setting of that flag in that case.

Pull Request: https://projects.blender.org/blender/blender/pulls/143660
2025-08-01 14:01:24 +02:00
2025-08-01 12:27:56 +02:00
2023-12-08 13:28:13 +11:00
2025-05-12 11:34:32 +02:00
2025-07-10 12:48:33 +10:00
2025-07-22 16:17:10 +10:00

Blender

Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing, motion tracking and video editing.

Blender screenshot

Project Pages

Development

License

Blender as a whole is licensed under the GNU General Public License, Version 3. Individual files may have a different but compatible license.

See blender.org/about/license for details.

Description
No description provided
Readme 841 MiB
Languages
C++ 78%
Python 14.9%
C 2.9%
GLSL 1.9%
CMake 1.2%
Other 0.9%