Fix empty nested class properties not being cleaned up (#3998)#4415
Fix empty nested class properties not being cleaned up (#3998)#4415Oval17 wants to merge 1 commit intomapeditor:masterfrom
Conversation
When resetting the last member of a top-level class property that is defined in the object's assigned class, the empty class container is now automatically removed, consistent with how deeper nesting levels already behave. Manually added class properties (not defined in the object's class) are still preserved when empty, to avoid accidentally losing them.
This comment has been minimized.
This comment has been minimized.
|
Hmm, it seems this patch really only changes the behavior of For the new behavior to work from the UI, we probably need to change I realize the whole setup is a little involved. There is another problematic aspect. We don't want to automatically reset a top-level class value when the class value inherited from the object's class is not an empty value. Because when we reset the top-level value when it's empty, it would revert back to inheriting the non-empty value. So at least in that case, the user needs to explicitly reset the top-level value if that it what they want. |
1 -> When all members of a top-level class property are reset, the empty class container is now automatically removed but only when that property is defined in the object's assigned class.
2 -> Previously, the cleanup in setClassPropertyValue was intentionally skipped at depth 1 (allowReset = false) to avoid removing manually-added class properties. This fix threads an
allowTopLevelResetflag through fromObject::setProperty, which sets it to true only when the top-level key exists inclassType()->members. Manually added properties (not defined in the object's class) are still preserved.Fixes #3998
Ready for Review and Inputs @bjorn