diff options
author | Bastien Montagne <bastien@blender.org> | 2022-05-23 13:11:09 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-05-23 13:11:09 +0300 |
commit | 62a2b92b6bef8b01bd4b34f02b188297e1f62c71 (patch) | |
tree | 7600cd627db1ca5057c8948a71ed293bdbac7734 | |
parent | a5409d2b5941a4292cc19f48cb8546e3ab91296f (diff) |
Fix T98283: Regression: crash when opening file that has Collision modifier on liboverride object
Some RNA property update callbacks can already generate such modifier,
and only one is allowed per object, so had to adapt code actually adding
new modifiers in liboverride apply codebase.
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 1fb41bf792f..98fc6633f78 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1829,6 +1829,24 @@ bool rna_Object_modifiers_override_apply(Main *bmain, ModifierData *mod_dst = ED_object_modifier_add( NULL, bmain, NULL, ob_dst, mod_src->name, mod_src->type); + if (mod_dst == NULL) { + /* This can happen e.g. when a modifier type is tagged as `eModifierTypeFlag_Single`, and that + * modifier has somehow been added already by another code path (e.g. + * `rna_CollisionSettings_dependency_update` does add the `eModifierType_Collision` singleton + * modifier). + * + * Try to handle this by finding already existing one here. */ + const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)mod_src->type); + if (mti->flags & eModifierTypeFlag_Single) { + mod_dst = BKE_modifiers_findby_type(ob_dst, (ModifierType)mod_src->type); + } + + if (mod_dst == NULL) { + BLI_assert(mod_src != NULL); + return false; + } + } + /* XXX Current handling of 'copy' from particle-system modifier is *very* bad (it keeps same psys * pointer as source, then calling code copies psys of object separately and do some magic * remapping of pointers...), unfortunately several pieces of code in Object editing area rely on |