From 2e8793b38f8088eec2d2d0fd334c0a27798ae62b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jun 2025 17:13:32 +1000 Subject: [PATCH] WM: prevent the same value being written multiple times in a preset Presets would write a property multiple times in the case both the class and it's parent defined a property. While not a bug, it looks like an error. Only write values once. --- scripts/startup/bl_operators/presets.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/startup/bl_operators/presets.py b/scripts/startup/bl_operators/presets.py index fad61f9841d..6f59368931e 100644 --- a/scripts/startup/bl_operators/presets.py +++ b/scripts/startup/bl_operators/presets.py @@ -166,9 +166,16 @@ class AddPresetBase: def rna_recursive_attr_expand(value, rna_path_step, level): if isinstance(value, bpy.types.PropertyGroup): + # Avoid properties being handled multiple times. + # This happens when a class defines a property which is also defined by it's parent class. + # The parents property is shadowed, so it only makes sense to write each property once. + # Happens with `OperatorFileListElement` which has two `name` properties. + properties_skip = {"rna_type"} for sub_value_attr in value.bl_rna.properties.keys(): - if sub_value_attr == "rna_type": + if sub_value_attr in properties_skip: continue + properties_skip.add(sub_value_attr) + sub_value = getattr(value, sub_value_attr) rna_recursive_attr_expand( sub_value,