From 99e8aeaa4a20933bdb6c7decafb0eac1e5bca002 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 2 Sep 2019 17:34:56 +0200 Subject: DatablockManagement: Fix/sanitize handling of flags for private ID data in copy functions. Not sure exactly why that was working with nodetrees in depsgraph (could be some special code in the despgraph), but we always want to allocate memory for the nodetrees here! --- source/blender/blenkernel/intern/light.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/light.c') diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index 75c9e0e42a5..07ec8d70af1 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -108,12 +108,15 @@ Light *BKE_light_add(Main *bmain, const char *name) */ void BKE_light_copy_data(Main *bmain, Light *la_dst, const Light *la_src, const int flag) { + /* We never handle usercount here for own data. */ + const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT; + /* We always need allocation of our private ID data. */ + const int flag_private_id_data = flag_subdata & ~LIB_ID_CREATE_NO_ALLOCATE; + la_dst->curfalloff = BKE_curvemapping_copy(la_src->curfalloff); if (la_src->nodetree) { - /* Note: nodetree is *not* in bmain, however this specific case is handled at lower level - * (see BKE_libblock_copy_ex()). */ - BKE_id_copy_ex(bmain, (ID *)la_src->nodetree, (ID **)&la_dst->nodetree, flag); + BKE_id_copy_ex(bmain, (ID *)la_src->nodetree, (ID **)&la_dst->nodetree, flag_private_id_data); } if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { -- cgit v1.2.3