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 fixblender/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