From 13f0b59f1180042b07f439d36841a52a6ddcd75e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 11 Jul 2016 19:39:34 +0200 Subject: 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. --- source/blender/blenkernel/intern/brush.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern/brush.c') 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); -- cgit v1.2.3