From 7212ebd09f9720883581221be923ae5e97ff5d76 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 11 Jul 2016 21:27:15 +0200 Subject: Remove usercount handling from BKE_id_expand_local. Idea looked good, but we have too much custom situations here (some half-fake-sub-ID being copied with their 'owner', animdata, etc.), let's let datablock copy functions handle that themselves. Also allows to safely call BKE_id_expand_local from all copy functions now (only when copying linked data). --- source/blender/blenkernel/BKE_library.h | 2 +- source/blender/blenkernel/intern/action.c | 5 ++--- source/blender/blenkernel/intern/armature.c | 5 ++--- source/blender/blenkernel/intern/brush.c | 14 +++++++++++--- source/blender/blenkernel/intern/camera.c | 5 ++--- source/blender/blenkernel/intern/curve.c | 12 ++++++++++-- source/blender/blenkernel/intern/group.c | 1 + source/blender/blenkernel/intern/image.c | 3 ++- source/blender/blenkernel/intern/key.c | 1 + source/blender/blenkernel/intern/lamp.c | 3 ++- source/blender/blenkernel/intern/lattice.c | 6 ++---- source/blender/blenkernel/intern/library.c | 23 +++++------------------ source/blender/blenkernel/intern/linestyle.c | 1 + source/blender/blenkernel/intern/mask.c | 1 + source/blender/blenkernel/intern/material.c | 5 +++-- source/blender/blenkernel/intern/mball.c | 9 ++++++--- source/blender/blenkernel/intern/mesh.c | 11 +++++++---- source/blender/blenkernel/intern/node.c | 3 ++- source/blender/blenkernel/intern/object.c | 4 ++-- source/blender/blenkernel/intern/particle.c | 6 +++--- source/blender/blenkernel/intern/speaker.c | 6 ++++-- source/blender/blenkernel/intern/text.c | 1 + source/blender/blenkernel/intern/texture.c | 7 ++++--- source/blender/blenkernel/intern/world.c | 3 ++- 24 files changed, 77 insertions(+), 60 deletions(-) diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index e63371900bf..d419d257471 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -84,7 +84,7 @@ bool id_make_local(struct Main *bmain, struct ID *id, bool test); bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop); bool id_copy(struct Main *bmain, struct ID *id, struct ID **newid, bool test); void id_sort_by_name(struct ListBase *lb, struct ID *id); -void BKE_id_expand_local(struct ID *id, const bool do_user_count); +void BKE_id_expand_local(struct ID *id); bool new_id(struct ListBase *lb, struct ID *id, const char *name); void id_clear_lib_data(struct Main *bmain, struct ID *id); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 1e5ad81773d..f7ff1261c8a 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -113,7 +113,7 @@ void BKE_action_make_local(Main *bmain, bAction *act) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &act->id); - BKE_id_expand_local(&act->id, false); + BKE_id_expand_local(&act->id); } else { bAction *act_new = BKE_action_copy(bmain, act); @@ -181,9 +181,8 @@ bAction *BKE_action_copy(Main *bmain, bAction *src) } } - BKE_id_expand_local(&dst->id, true); - if (ID_IS_LINKED_DATABLOCK(src)) { + BKE_id_expand_local(&dst->id); BKE_id_lib_local_paths(bmain, src->id.lib, &dst->id); } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 47fa0e9ca7f..5f564e1c4d2 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -162,7 +162,7 @@ void BKE_armature_make_local(Main *bmain, bArmature *arm) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &arm->id); - BKE_id_expand_local(&arm->id, false); + BKE_id_expand_local(&arm->id); } else { bArmature *arm_new = BKE_armature_copy(bmain, arm); @@ -219,9 +219,8 @@ bArmature *BKE_armature_copy(Main *bmain, bArmature *arm) newArm->act_edbone = NULL; newArm->sketch = NULL; - BKE_id_expand_local(&newArm->id, true); - if (ID_IS_LINKED_DATABLOCK(arm)) { + BKE_id_expand_local(&newArm->id); BKE_id_lib_local_paths(bmain, arm->id.lib, &newArm->id); } diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 1f48d5835b7..20621feac6c 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -178,6 +178,15 @@ Brush *BKE_brush_copy(Main *bmain, Brush *brush) brushn = BKE_libblock_copy(bmain, &brush->id); + if (brush->mtex.tex) + id_us_plus((ID *)brush->mtex.tex); + + if (brush->mask_mtex.tex) + id_us_plus((ID *)brush->mask_mtex.tex); + + if (brush->paint_curve) + id_us_plus((ID *)brush->paint_curve); + if (brush->icon_imbuf) brushn->icon_imbuf = IMB_dupImBuf(brush->icon_imbuf); @@ -188,9 +197,8 @@ Brush *BKE_brush_copy(Main *bmain, Brush *brush) /* enable fake user by default */ id_fake_user_set(&brush->id); - BKE_id_expand_local(&brushn->id, true); - if (ID_IS_LINKED_DATABLOCK(brush)) { + BKE_id_expand_local(&brushn->id); BKE_id_lib_local_paths(bmain, brush->id.lib, &brushn->id); } @@ -234,7 +242,7 @@ void BKE_brush_make_local(Main *bmain, Brush *brush) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &brush->id); - BKE_id_expand_local(&brush->id, false); + BKE_id_expand_local(&brush->id); /* enable fake user by default */ id_fake_user_set(&brush->id); diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 972057fd2dd..ae7aac8b54f 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -99,9 +99,8 @@ Camera *BKE_camera_copy(Main *bmain, Camera *cam) camn = BKE_libblock_copy(bmain, &cam->id); - BKE_id_expand_local(&camn->id, true); - if (ID_IS_LINKED_DATABLOCK(cam)) { + BKE_id_expand_local(&camn->id); BKE_id_lib_local_paths(bmain, cam->id.lib, &camn->id); } @@ -126,7 +125,7 @@ void BKE_camera_make_local(Main *bmain, Camera *cam) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &cam->id); - BKE_id_expand_local(&cam->id, false); + BKE_id_expand_local(&cam->id); } else { Camera *cam_new = BKE_camera_copy(bmain, cam); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index db5bbe30759..0e634e21ea3 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -177,6 +177,7 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type) Curve *BKE_curve_copy(Main *bmain, Curve *cu) { Curve *cun; + int a; cun = BKE_libblock_copy(bmain, &cu->id); @@ -184,6 +185,9 @@ Curve *BKE_curve_copy(Main *bmain, Curve *cu) BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb)); cun->mat = MEM_dupallocN(cu->mat); + for (a = 0; a < cun->totcol; a++) { + id_us_plus((ID *)cun->mat[a]); + } cun->str = MEM_dupallocN(cu->str); cun->strinfo = MEM_dupallocN(cu->strinfo); @@ -192,16 +196,19 @@ Curve *BKE_curve_copy(Main *bmain, Curve *cu) if (cu->key) { cun->key = BKE_key_copy(bmain, cu->key); - cun->key->id.us = 0; /* Will be increased again by BKE_id_expand_local. */ cun->key->from = (ID *)cun; } cun->editnurb = NULL; cun->editfont = NULL; - BKE_id_expand_local(&cun->id, true); + id_us_plus((ID *)cun->vfont); + id_us_plus((ID *)cun->vfontb); + id_us_plus((ID *)cun->vfonti); + id_us_plus((ID *)cun->vfontbi); if (ID_IS_LINKED_DATABLOCK(cu)) { + BKE_id_expand_local(&cun->id); BKE_id_lib_local_paths(bmain, cu->id.lib, &cun->id); } @@ -229,6 +236,7 @@ void BKE_curve_make_local(Main *bmain, Curve *cu) if (cu->key) { BKE_key_make_local(bmain, cu->key); } + BKE_id_expand_local(&cu->id); } else { Curve *cu_new = BKE_curve_copy(bmain, cu); diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 99a83665db7..11bbd91e9c9 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -98,6 +98,7 @@ Group *BKE_group_copy(Main *bmain, Group *group) groupn->preview = NULL; if (ID_IS_LINKED_DATABLOCK(group)) { + BKE_id_expand_local(&groupn->id); BKE_id_lib_local_paths(bmain, group->id.lib, &groupn->id); } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ae5c2b80c21..f6f38977402 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -462,6 +462,7 @@ Image *BKE_image_copy(Main *bmain, Image *ima) nima->preview = BKE_previewimg_copy(ima->preview); if (ID_IS_LINKED_DATABLOCK(ima)) { + BKE_id_expand_local(&nima->id); BKE_id_lib_local_paths(bmain, ima->id.lib, &nima->id); } @@ -486,7 +487,7 @@ void BKE_image_make_local(Main *bmain, Image *ima) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &ima->id); - BKE_id_expand_local(&ima->id, false); + BKE_id_expand_local(&ima->id); } else { Image *ima_new = BKE_image_copy(bmain, ima); diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 2b7968eec1d..e59facd3c39 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -171,6 +171,7 @@ Key *BKE_key_copy(Main *bmain, Key *key) } if (ID_IS_LINKED_DATABLOCK(key)) { + BKE_id_expand_local(&keyn->id); BKE_id_lib_local_paths(bmain, key->id.lib, &keyn->id); } diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 84862817ce3..003b154a70b 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -139,6 +139,7 @@ Lamp *BKE_lamp_copy(Main *bmain, Lamp *la) lan->preview = BKE_previewimg_copy(la->preview); if (ID_IS_LINKED_DATABLOCK(la)) { + BKE_id_expand_local(&lan->id); BKE_id_lib_local_paths(bmain, la->id.lib, &lan->id); } @@ -189,7 +190,7 @@ void BKE_lamp_make_local(Main *bmain, Lamp *la) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &la->id); - BKE_id_expand_local(&la->id, false); + BKE_id_expand_local(&la->id); } else { Lamp *la_new = BKE_lamp_copy(bmain, la); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index c2a94efb963..67f49266efc 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -286,7 +286,6 @@ Lattice *BKE_lattice_copy(Main *bmain, Lattice *lt) if (lt->key) { ltn->key = BKE_key_copy(bmain, ltn->key); - ltn->key->id.us = 0; /* Will be increased again by BKE_id_expand_local. */ ltn->key->from = (ID *)ltn; } @@ -298,9 +297,8 @@ Lattice *BKE_lattice_copy(Main *bmain, Lattice *lt) ltn->editlatt = NULL; - BKE_id_expand_local(<n->id, true); - if (ID_IS_LINKED_DATABLOCK(lt)) { + BKE_id_expand_local(<n->id); BKE_id_lib_local_paths(bmain, lt->id.lib, <n->id); } @@ -353,7 +351,7 @@ void BKE_lattice_make_local(Main *bmain, Lattice *lt) if (lt->key) { BKE_key_make_local(bmain, lt->key); } - BKE_id_expand_local(<->id, false); + BKE_id_expand_local(<->id); } else { Lattice *lt_new = BKE_lattice_copy(bmain, lt); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 678ac662ae3..869e02448ea 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -251,22 +251,11 @@ void id_fake_user_clear(ID *id) } } -static int id_expand_local_callback(void *user_data, struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag) +static int id_expand_local_callback( + void *UNUSED(user_data), struct ID *UNUSED(id_self), struct ID **id_pointer, int UNUSED(cd_flag)) { - const bool do_user_count = (user_data != NULL); - - /* We tag all ID usages as extern, and increase usercount in case it was requested. */ if (*id_pointer) { - if (do_user_count && (cd_flag & IDWALK_USER) && - /* XXX This is a hack - animdata copying needs a good check and cleanup, it's done with way too much - * various functions currently, so for now we assume actions' usercount is already handled here... */ - (GS((*id_pointer)->name) != ID_AC)) - { - id_us_plus(*id_pointer); - } - else { - id_lib_extern(*id_pointer); - } + id_lib_extern(*id_pointer); } return IDWALK_RET_NOP; @@ -274,12 +263,10 @@ static int id_expand_local_callback(void *user_data, struct ID *UNUSED(id_self), /** * Expand ID usages of given id as 'extern' (and no more indirect) linked data. Used by ID copy/make_local functions. - * - * \param do_user_count If true, increase usercount of refcounted datablocks used by given id (use it with copied id). */ -void BKE_id_expand_local(struct ID *id, const bool do_user_count) +void BKE_id_expand_local(ID *id) { - BKE_library_foreach_ID_link(id, id_expand_local_callback, SET_INT_IN_POINTER((int)do_user_count), 0); + BKE_library_foreach_ID_link(id, id_expand_local_callback, NULL, 0); } /* calls the appropriate make_local method for the block, unless test. Returns true diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index 12fb42bea5f..c4a0d0074fb 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -219,6 +219,7 @@ FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, FreestyleLineStyle *l BKE_linestyle_geometry_modifier_copy(new_linestyle, m); if (ID_IS_LINKED_DATABLOCK(linestyle)) { + BKE_id_expand_local(&new_linestyle->id); BKE_id_lib_local_paths(bmain, linestyle->id.lib, &new_linestyle->id); } diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index b5bb57ad123..9e070bbef22 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -854,6 +854,7 @@ Mask *BKE_mask_copy(Main *bmain, Mask *mask) id_fake_user_set(&mask->id); if (ID_IS_LINKED_DATABLOCK(mask)) { + BKE_id_expand_local(&mask_new->id); BKE_id_lib_local_paths(bmain, mask->id.lib, &mask_new->id); } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 5583702aab3..17811893c03 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -246,8 +246,9 @@ Material *BKE_material_copy(Main *bmain, Material *ma) man->preview = BKE_previewimg_copy(ma->preview); BLI_listbase_clear(&man->gpumaterial); - + if (ID_IS_LINKED_DATABLOCK(ma)) { + BKE_id_expand_local(&man->id); BKE_id_lib_local_paths(bmain, ma->id.lib, &man->id); } @@ -302,7 +303,7 @@ void BKE_material_make_local(Main *bmain, Material *ma) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &ma->id); - BKE_id_expand_local(&ma->id, false); + BKE_id_expand_local(&ma->id); } else { Material *ma_new = BKE_material_copy(bmain, ma); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index b65df04804d..9a0a6e3540c 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -105,19 +105,22 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name) MetaBall *BKE_mball_copy(Main *bmain, MetaBall *mb) { MetaBall *mbn; + int a; mbn = BKE_libblock_copy(bmain, &mb->id); BLI_duplicatelist(&mbn->elems, &mb->elems); mbn->mat = MEM_dupallocN(mb->mat); + for (a = 0; a < mbn->totcol; a++) { + id_us_plus((ID *)mbn->mat[a]); + } mbn->editelems = NULL; mbn->lastelem = NULL; - BKE_id_expand_local(&mbn->id, true); - if (ID_IS_LINKED_DATABLOCK(mb)) { + BKE_id_expand_local(&mbn->id); BKE_id_lib_local_paths(bmain, mb->id.lib, &mbn->id); } @@ -142,7 +145,7 @@ void BKE_mball_make_local(Main *bmain, MetaBall *mb) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &mb->id); - BKE_id_expand_local(&mb->id, false); + BKE_id_expand_local(&mb->id); } else { MetaBall *mb_new = BKE_mball_copy(bmain, mb); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 66adea04f67..787b9905734 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -496,11 +496,16 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name) Mesh *BKE_mesh_copy(Main *bmain, Mesh *me) { Mesh *men; + int a; const int do_tessface = ((me->totface != 0) && (me->totpoly == 0)); /* only do tessface if we have no polys */ men = BKE_libblock_copy(bmain, &me->id); men->mat = MEM_dupallocN(me->mat); + for (a = 0; a < men->totcol; a++) { + id_us_plus((ID *)men->mat[a]); + } + id_us_plus((ID *)men->texcomesh); CustomData_copy(&me->vdata, &men->vdata, CD_MASK_MESH, CD_DUPLICATE, men->totvert); CustomData_copy(&me->edata, &men->edata, CD_MASK_MESH, CD_DUPLICATE, men->totedge); @@ -522,13 +527,11 @@ Mesh *BKE_mesh_copy(Main *bmain, Mesh *me) if (me->key) { men->key = BKE_key_copy(bmain, me->key); - men->id.us = 0; /* Will be increased again by BKE_id_expand_local. */ men->key->from = (ID *)men; } - BKE_id_expand_local(&men->id, true); - if (ID_IS_LINKED_DATABLOCK(me)) { + BKE_id_expand_local(&men->id); BKE_id_lib_local_paths(bmain, me->id.lib, &men->id); } @@ -573,7 +576,7 @@ void BKE_mesh_make_local(Main *bmain, Mesh *me) if (me->key) { BKE_key_make_local(bmain, me->key); } - BKE_id_expand_local(&me->id, false); + BKE_id_expand_local(&me->id); } else { Mesh *me_new = BKE_mesh_copy(bmain, me); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index a9c0e80d815..296a00388c4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1292,6 +1292,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, Main *bmain, bool ski newtree->interface_type = NULL; if (ID_IS_LINKED_DATABLOCK(ntree)) { + BKE_id_expand_local(&newtree->id); BKE_id_lib_local_paths(bmain, ntree->id.lib, &newtree->id); } @@ -1968,7 +1969,7 @@ void ntreeMakeLocal(Main *bmain, bNodeTree *ntree, bool id_in_mainlist) if (is_local) { if (!is_lib) { id_clear_lib_data_ex(bmain, (ID *)ntree, id_in_mainlist); - BKE_id_expand_local(&ntree->id, false); + BKE_id_expand_local(&ntree->id); } else { bNodeTree *ntree_new = ntreeCopyTree(bmain, ntree); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 1d2f2ab5ddf..30a193506a6 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1166,11 +1166,11 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches) copy_object_lod(obn, ob); - /* Copy runtime surve data. */ obn->curve_cache = NULL; if (ID_IS_LINKED_DATABLOCK(ob)) { + BKE_id_expand_local(&obn->id); BKE_id_lib_local_paths(bmain, ob->id.lib, &obn->id); } @@ -1204,7 +1204,7 @@ void BKE_object_make_local(Main *bmain, Object *ob) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &ob->id); - BKE_id_expand_local(&ob->id, false); + BKE_id_expand_local(&ob->id); } else { Object *ob_new = BKE_object_copy(bmain, ob); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f50f8cfb4cb..934c5b9ff06 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3329,14 +3329,14 @@ ParticleSettings *BKE_particlesettings_copy(Main *bmain, ParticleSettings *part) if (part->mtex[a]) { partn->mtex[a] = MEM_mallocN(sizeof(MTex), "psys_copy_tex"); memcpy(partn->mtex[a], part->mtex[a], sizeof(MTex)); + id_us_plus((ID *)partn->mtex[a]->tex); } } BLI_duplicatelist(&partn->dupliweights, &part->dupliweights); - BKE_id_expand_local(&partn->id, true); - if (ID_IS_LINKED_DATABLOCK(part)) { + BKE_id_expand_local(&partn->id); BKE_id_lib_local_paths(bmain, part->id.lib, &partn->id); } @@ -3361,7 +3361,7 @@ void BKE_particlesettings_make_local(Main *bmain, ParticleSettings *part) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &part->id); - BKE_id_expand_local(&part->id, false); + BKE_id_expand_local(&part->id); } else { ParticleSettings *part_new = BKE_particlesettings_copy(bmain, part); diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index 8fb12d5db16..a91d8657179 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -74,9 +74,11 @@ Speaker *BKE_speaker_copy(Main *bmain, Speaker *spk) spkn = BKE_libblock_copy(bmain, &spk->id); - BKE_id_expand_local(&spkn->id, true); + if (spkn->sound) + id_us_plus(&spkn->sound->id); if (ID_IS_LINKED_DATABLOCK(spk)) { + BKE_id_expand_local(&spkn->id); BKE_id_lib_local_paths(G.main, spk->id.lib, &spkn->id); } @@ -101,7 +103,7 @@ void BKE_speaker_make_local(Main *bmain, Speaker *spk) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &spk->id); - BKE_id_expand_local(&spk->id, false); + BKE_id_expand_local(&spk->id); } else { Speaker *spk_new = BKE_speaker_copy(bmain, spk); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 6beaba1b41c..269d6d32b31 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -492,6 +492,7 @@ Text *BKE_text_copy(Main *bmain, Text *ta) init_undo_text(tan); if (ID_IS_LINKED_DATABLOCK(ta)) { + BKE_id_expand_local(&tan->id); BKE_id_lib_local_paths(bmain, ta->id.lib, &tan->id); } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index a5088e94ada..e34d632f2ca 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -872,12 +872,13 @@ Tex *BKE_texture_copy(Main *bmain, Tex *tex) texn->nodetree = ntreeCopyTree(bmain, tex->nodetree); } + texn->preview = BKE_previewimg_copy(tex->preview); + if (ID_IS_LINKED_DATABLOCK(tex)) { + BKE_id_expand_local(&texn->id); BKE_id_lib_local_paths(bmain, tex->id.lib, &texn->id); } - texn->preview = BKE_previewimg_copy(tex->preview); - return texn; } @@ -935,7 +936,7 @@ void BKE_texture_make_local(Main *bmain, Tex *tex) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &tex->id); - BKE_id_expand_local(&tex->id, false); + BKE_id_expand_local(&tex->id); } else { Tex *tex_new = BKE_texture_copy(bmain, tex); diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index ca9ff889e2d..9795a8174f8 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -143,6 +143,7 @@ World *BKE_world_copy(Main *bmain, World *wrld) BLI_listbase_clear(&wrldn->gpumaterial); if (ID_IS_LINKED_DATABLOCK(wrld)) { + BKE_id_expand_local(&wrldn->id); BKE_id_lib_local_paths(bmain, wrld->id.lib, &wrldn->id); } @@ -193,7 +194,7 @@ void BKE_world_make_local(Main *bmain, World *wrld) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &wrld->id); - BKE_id_expand_local(&wrld->id, false); + BKE_id_expand_local(&wrld->id); } else { World *wrld_new = BKE_world_copy(bmain, wrld); -- cgit v1.2.3