Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-05-23 13:11:09 +0300
committerBastien Montagne <bastien@blender.org>2022-05-23 13:13:33 +0300
commita833c7f4a54e24fb3012311636bf7b1949b20eaf (patch)
tree6a24ced8f7c52c9102d6b5bffb80980b602d76bc /source/blender/makesrna/intern/rna_object.c
parentf626fc27f9e2d3ee4b694b3c597b867f5650a019 (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.
Diffstat (limited to 'source/blender/makesrna/intern/rna_object.c')
-rw-r--r--source/blender/makesrna/intern/rna_object.c18
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