Page MenuHome

RNA: allow editing pointer IDProperty values from the UI.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Jan 12 2021, 7:11 PM.

Details

Summary

Currently it is not possible to edit bare IDProperty pointer
values which are not explicitly defined through python via
UI fields. This is likely mostly because, unlike numeric values,
pointers aren't marked PROP_EDITABLE by default, seeng as flags
include PROP_NEVER_UNLINK, which seems useless for an intentionally
readonly property. However there are also some bugs in the
RNA code that need fixing.

The Geometry Nodes modifier uses bare properties to store
input settings for the node group it wraps, so supporting
Object and Collection sockets requires editable pointers.

This patch marks bare IDProperties editable, fixes a crash
bug in RNA_property_pointer_set due to the wrong order of
operations, and ensures that changing ID pointers rebuilds
the dependency graph. A type check is needed because an
IDPROPERTY PointerPropertyRNA can actually wrap a group
value rather than an ID pointer.

Making pointers editable is not likely to accidentally
affect UI fields that were not intended to be editable,
because a simple layout.prop cannot determine which
datablocks to display in the menu and remains read-only.

Actual support for Object & Collection inputs in the modifier
is added in D10056, which can be used to test this code.

Diff Detail

Repository
rB Blender

Event Timeline

Alexander Gavrilov (angavrilov) requested review of this revision.Jan 12 2021, 7:11 PM

Generally looks fine now, besides point noted in comment below.

Also, please be sure to commit this in two steps (one for the fix in RNA_property_pointer_set, the other for IDProps flags and update handling).

source/blender/makesrna/intern/rna_ID.c
1116

Not sure we should keep the PROP_NEVER_UNLINK then? IMHO we might want to un-assign IDs from those as well? Isn't that needed int the geometry nodes context?

Removed PROP_NEVER_UNLINK - seems it's not needed anymore for the original purpose.

This revision is now accepted and ready to land.Jan 13 2021, 11:48 AM