diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-04-04 16:03:55 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-04-04 16:03:55 +0300 |
commit | 160e62b88cdcc927b7cb3741c7ea0565412e8016 (patch) | |
tree | 3561447e02e088a056f85f10d13094a7fb49b9ca /source/blender/blenkernel | |
parent | 59562e5b259ccc1e02e4f943394ca9db5ac938c7 (diff) | |
parent | d59c2d12b1226afa3789b0ef142f8f6cc9356ead (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/blenkernel/BKE_object.h
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 24 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 9 |
5 files changed, 31 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index e1ce58ba69b..7eb3ad33950 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -332,6 +332,7 @@ const ModifierTypeInfo *modifierType_getInfo(ModifierType type); * default values if pointer is optional. */ struct ModifierData *modifier_new(int type); +void modifier_free_ex(struct ModifierData *md, const int flag); void modifier_free(struct ModifierData *md); bool modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 11e259e0318..1af31d5e024 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -77,7 +77,7 @@ bool BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type void BKE_object_link_modifiers( struct Object *ob_dst, const struct Object *ob_src, eObjectMode object_mode); -void BKE_object_free_modifiers(struct Object *ob); +void BKE_object_free_modifiers(struct Object *ob, const int flag); void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index abbf073f646..8c88430aa10 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2469,7 +2469,7 @@ Mesh *BKE_mesh_new_from_object( /* if getting the original caged mesh, delete object modifiers */ if (cage) - BKE_object_free_modifiers(tmpobj); + BKE_object_free_modifiers(tmpobj, 0); /* copies the data */ copycu = tmpobj->data = BKE_curve_copy(bmain, (Curve *) ob->data); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 1604a017054..1f570dcb531 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -138,16 +138,38 @@ ModifierData *modifier_new(int type) return md; } -void modifier_free(ModifierData *md) +static void modifier_free_data_id_us_cb(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin, int cb_flag) +{ + ID *id = *idpoin; + if (id != NULL && (cb_flag & IDWALK_CB_USER) != 0) { + id_us_min(id); + } +} + +void modifier_free_ex(ModifierData *md, const int flag) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); + if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { + if (mti->foreachIDLink) { + mti->foreachIDLink(md, NULL, modifier_free_data_id_us_cb, NULL); + } + else if (mti->foreachObjectLink) { + mti->foreachObjectLink(md, NULL, (ObjectWalkFunc)modifier_free_data_id_us_cb, NULL); + } + } + if (mti->freeData) mti->freeData(md); if (md->error) MEM_freeN(md->error); MEM_freeN(md); } +void modifier_free(ModifierData *md) +{ + modifier_free_ex(md, 0); +} + bool modifier_unique_name(ListBase *modifiers, ModifierData *md) { if (modifiers && md) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 73f47dec9cb..59d2bcc89fd 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -198,12 +198,12 @@ void BKE_object_free_curve_cache(Object *ob) } } -void BKE_object_free_modifiers(Object *ob) +void BKE_object_free_modifiers(Object *ob, const int flag) { ModifierData *md; while ((md = BLI_pophead(&ob->modifiers))) { - modifier_free(md); + modifier_free_ex(md, flag); } /* particle modifiers were freed, so free the particlesystems as well */ @@ -267,7 +267,7 @@ void BKE_object_link_modifiers( eObjectMode object_mode) { ModifierData *md; - BKE_object_free_modifiers(ob_dst); + BKE_object_free_modifiers(ob_dst, 0); if (!ELEM(ob_dst->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { /* only objects listed above can have modifiers and linking them to objects @@ -421,7 +421,8 @@ void BKE_object_free(Object *ob) { BKE_animdata_free((ID *)ob, false); - BKE_object_free_modifiers(ob); + /* BKE_<id>_free shall never touch to ID->us. Never ever. */ + BKE_object_free_modifiers(ob, LIB_ID_CREATE_NO_USER_REFCOUNT); MEM_SAFE_FREE(ob->mat); MEM_SAFE_FREE(ob->matbits); |