From 7c9131d11eb01a70db440fac7bb3f4b3833d544a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 7 Oct 2020 14:27:33 +0200 Subject: Refactor `BKE_id_copy_ex` to return the new ID pointer. Note that possibility to pass the new ID pointer as parameter was kept, as this is needed for some rather specific cases (like in depsgraph/COW, when copying into already allocated memory). Part of T71219. --- source/blender/editors/render/render_preview.c | 17 +++++++---------- source/blender/editors/render/render_shading.c | 8 ++++---- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'source/blender/editors/render') diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index d7eaaf3277b..6369b7bad43 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -326,11 +326,11 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world) return sp->worldcopy; } - ID *id_copy; - BKE_id_copy_ex(NULL, - &world->id, - &id_copy, - LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA); + ID *id_copy = BKE_id_copy_ex(NULL, + &world->id, + NULL, + LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE | + LIB_ID_COPY_NO_ANIMDATA); sp->worldcopy = (World *)id_copy; BLI_addtail(&sp->pr_main->worlds, sp->worldcopy); return sp->worldcopy; @@ -348,11 +348,8 @@ static ID *duplicate_ids(ID *id) case ID_TE: case ID_LA: case ID_WO: { - ID *id_copy; - BKE_id_copy_ex(NULL, - id, - &id_copy, - LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA); + ID *id_copy = BKE_id_copy_ex( + NULL, id, NULL, LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA); return id_copy; } case ID_IM: diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 5ebf2a3915d..425537b5e13 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -751,8 +751,8 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy material */ if (ma) { - Material *new_ma = NULL; - BKE_id_copy_ex(bmain, &ma->id, (ID **)&new_ma, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); + Material *new_ma = (Material *)BKE_id_copy_ex( + bmain, &ma->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); ma = new_ma; } else { @@ -873,8 +873,8 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy world */ if (wo) { - World *new_wo = NULL; - BKE_id_copy_ex(bmain, &wo->id, (ID **)&new_wo, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); + World *new_wo = (World *)BKE_id_copy_ex( + bmain, &wo->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); wo = new_wo; } else { -- cgit v1.2.3