diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-11 20:39:34 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-11 22:30:02 +0300 |
commit | 13f0b59f1180042b07f439d36841a52a6ddcd75e (patch) | |
tree | 29c32ac5edaaf896d6f9d4ff29ecb81a1654feaa /source/blender/blenkernel/intern | |
parent | 2ec17e655c4fdabc6251b5c81f4404451160923c (diff) |
Use new generic BKE_id_expand_local() for both make_local() and copy() functions of actions, brushes and particles.
This greatly simplifies said code, once again no change expected from user PoV.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 28 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 21 |
3 files changed, 10 insertions, 42 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index aa733e8d90e..5712026a554 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -113,6 +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); } else { bAction *act_new = BKE_action_copy(bmain, act); @@ -183,6 +184,8 @@ bAction *BKE_action_copy(Main *bmain, bAction *src) } } + BKE_id_expand_local(&dst->id, true); + if (ID_IS_LINKED_DATABLOCK(src)) { BKE_id_lib_local_paths(bmain, src->id.lib, &dst->id); } diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index ee7af7e6dd1..814934a9190 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -178,15 +178,6 @@ 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); @@ -197,6 +188,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_lib_local_paths(bmain, brush->id.lib, &brushn->id); } @@ -218,21 +211,6 @@ void BKE_brush_free(Brush *brush) BKE_previewimg_free(&(brush->preview)); } -static int extern_local_brush_callback( - void *UNUSED(user_data), struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag) -{ - /* We only tag usercounted ID usages as extern... Why? */ - if ((cd_flag & IDWALK_USER) && *id_pointer) { - id_lib_extern(*id_pointer); - } - return IDWALK_RET_NOP; -} - -static void extern_local_brush(Brush *brush) -{ - BKE_library_foreach_ID_link(&brush->id, extern_local_brush_callback, NULL, 0); -} - void BKE_brush_make_local(Main *bmain, Brush *brush) { bool is_local = false, is_lib = false; @@ -256,7 +234,7 @@ void BKE_brush_make_local(Main *bmain, Brush *brush) if (is_local) { if (!is_lib) { id_clear_lib_data(bmain, &brush->id); - extern_local_brush(brush); + BKE_id_expand_local(&brush->id, false); /* enable fake user by default */ id_fake_user_set(&brush->id); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 8c8a78941d7..8d42aae12d5 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3312,6 +3312,7 @@ ParticleSettings *BKE_particlesettings_copy(Main *bmain, ParticleSettings *part) int a; partn = BKE_libblock_copy(bmain, &part->id); + partn->pd = MEM_dupallocN(part->pd); partn->pd2 = MEM_dupallocN(part->pd2); partn->effector_weights = MEM_dupallocN(part->effector_weights); @@ -3328,12 +3329,13 @@ 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_lib_local_paths(bmain, part->id.lib, &partn->id); } @@ -3341,21 +3343,6 @@ ParticleSettings *BKE_particlesettings_copy(Main *bmain, ParticleSettings *part) return partn; } -static int extern_local_particlesettings_callback( - void *UNUSED(user_data), struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag) -{ - /* We only tag usercounted ID usages as extern... Why? */ - if ((cd_flag & IDWALK_USER) && *id_pointer) { - id_lib_extern(*id_pointer); - } - return IDWALK_RET_NOP; -} - -static void expand_local_particlesettings(ParticleSettings *part) -{ - BKE_library_foreach_ID_link(&part->id, extern_local_particlesettings_callback, NULL, 0); -} - void BKE_particlesettings_make_local(Main *bmain, ParticleSettings *part) { bool is_local = false, is_lib = false; @@ -3374,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); - expand_local_particlesettings(part); + BKE_id_expand_local(&part->id, false); } else { ParticleSettings *part_new = BKE_particlesettings_copy(bmain, part); |