Add BKE_key_copy_ex() that takes a Main as parameter.

This commit is contained in:
Bastien Montagne 2016-07-09 15:43:45 +02:00
parent 429394078b
commit ae2033aca2
Notes: blender-bot 2023-02-14 07:45:41 +01:00
Referenced by issue #48822, Crash when I try to use "Join" (Ctrl Key + J) with two meshes
Referenced by issue #48824, Cycles: Crash with glass+volume(?)
6 changed files with 12 additions and 7 deletions

View File

@ -52,6 +52,7 @@ void BKE_key_free(struct Key *sc);
void BKE_key_free_nolib(struct Key *key);
struct Key *BKE_key_add(struct ID *id);
struct Key *BKE_key_copy(struct Key *key);
struct Key *BKE_key_copy_ex(struct Main *bmain, struct Key *key);
struct Key *BKE_key_copy_nolib(struct Key *key);
void BKE_key_make_local(struct Main *bmain, struct Key *key);
void BKE_key_sort(struct Key *key);

View File

@ -195,7 +195,7 @@ Curve *BKE_curve_copy_ex(Main *bmain, Curve *cu)
cun->bb = MEM_dupallocN(cu->bb);
if (cu->key) {
cun->key = BKE_key_copy(cu->key);
cun->key = BKE_key_copy_ex(bmain, cu->key);
cun->key->from = (ID *)cun;
}

View File

@ -150,12 +150,12 @@ Key *BKE_key_add(ID *id) /* common function */
return key;
}
Key *BKE_key_copy(Key *key)
Key *BKE_key_copy_ex(Main *bmain, Key *key)
{
Key *keyn;
KeyBlock *kbn, *kb;
keyn = BKE_libblock_copy(&key->id);
keyn = BKE_libblock_copy_ex(bmain, &key->id);
BLI_duplicatelist(&keyn->block, &key->block);
@ -171,12 +171,16 @@ Key *BKE_key_copy(Key *key)
}
if (ID_IS_LINKED_DATABLOCK(key)) {
BKE_id_lib_local_paths(G.main, key->id.lib, &keyn->id);
BKE_id_lib_local_paths(bmain, key->id.lib, &keyn->id);
}
return keyn;
}
Key *BKE_key_copy(Key *key)
{
return BKE_key_copy_ex(G.main, key);
}
Key *BKE_key_copy_nolib(Key *key)
{

View File

@ -285,7 +285,7 @@ Lattice *BKE_lattice_copy_ex(Main *bmain, Lattice *lt)
ltn->def = MEM_dupallocN(lt->def);
if (lt->key) {
ltn->key = BKE_key_copy(ltn->key);
ltn->key = BKE_key_copy_ex(bmain, ltn->key);
ltn->key->from = (ID *)ltn;
}

View File

@ -549,7 +549,7 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
men->bb = MEM_dupallocN(men->bb);
if (me->key) {
men->key = BKE_key_copy(me->key);
men->key = BKE_key_copy_ex(bmain, me->key);
men->key->from = (ID *)men;
}

View File

@ -172,7 +172,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
*/
if (key) {
/* make a duplicate copy that will only be used here... (must remember to free it!) */
nkey = BKE_key_copy(key);
nkey = BKE_key_copy_ex(bmain, key);
/* for all keys in old block, clear data-arrays */
for (kb = key->block.first; kb; kb = kb->next) {