Page MenuHome

Fix T90732: crash when alt+LMB to change custom properties of different bones
Needs RevisionPublic

Authored by Christoph Lendenfeld (ChrisLend) on Dec 15 2022, 1:44 PM.

Details

Summary

The issue occured only on pose bones when ALT dragging a property that existed on the active bone but not on the selected.

I also couldn't reproduce the issue with a Release build. Only in Debug it crashed.

It seems the PropertyRNA was invalid while the PointerRNA was valid.
But I might be wrong on that, the RNA system is still a mystery to me

Diff Detail

Repository
rB Blender

Event Timeline

This is a tricky thing. Your patch indeed prevents the crash, but it also prevents updating multiple IDs that have the same property. You can see that with the attached file, where bones A and C have the custom property, but bone B does not. In master (with a release build so it doesn't crash), selecting all and alt-dragging the property will manipulate all bones that actually have this property.

@Bastien Montagne (mont29) could you help a hand here?

Bastien Montagne (mont29) requested changes to this revision.Jan 6 2023, 12:32 PM
Bastien Montagne (mont29) added inline comments.
source/blender/editors/interface/interface_ops.cc
1327–1328

This should rather use RNA_struct_contains_property I think? That way you check that the RNA pointer do have that property, since by definition custom properties are not part of the RNA struct type...

This revision now requires changes to proceed.Jan 6 2023, 12:32 PM

Although reading the code of RNA_struct_contains_property I think you'll have to update it first to also check for ID properties...

Hrmmpppf... things are actually more complicated... Issue is, when there is no path given, lprop is just assigned from prop, which is fine for regular RNA properties, but absolute nonsense for IDProperties.

Think UI_context_copy_to_selected_check should check early for given prop being an IDProperty, and change how it handles non-path case then (since it cannot just assign prop to lprop then, but rather has to search for a matching new lprop in IDProperties from ptr_link.

Can't see a better way to do so, than to create the path from ptr to prop (RNA_path_from_struct_to_idproperty) in that case, and then try to resolve that path on ptr_link, and return false in case it cannot be found.

Having an assert that prop != lprop in case prop is an IDProperty is also probably a good idea.

@Bastien Montagne (mont29) Sorry I need a bit more guidance on this, how do I get an IDProperty from a PropertyRNA?

Checking if a RNA property is actually an IDProperty can be done with RNA_property_is_idprop. Don't think you actually need to get the IDProperty, everything should be doable through the RNA API as described in my previous comment?