From bfbac9b4489e9dedd5a0988e7eda0e2a5cbc53a9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 10 Jun 2013 14:04:03 +0000 Subject: Fix #35678: Duplicating an object with Displace modifier does not increase the reference count of the texture --- source/blender/modifiers/intern/MOD_displace.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source/blender/modifiers/intern') diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index d8e2647426c..ffd202736a9 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -42,6 +42,7 @@ #include "BKE_cdderivedmesh.h" +#include "BKE_library.h" #include "BKE_modifier.h" #include "BKE_texture.h" #include "BKE_deform.h" @@ -79,6 +80,18 @@ static void copyData(ModifierData *md, ModifierData *target) tdmd->texmapping = dmd->texmapping; tdmd->map_object = dmd->map_object; BLI_strncpy(tdmd->uvlayer_name, dmd->uvlayer_name, sizeof(tdmd->uvlayer_name)); + + if (tdmd->texture) { + id_us_plus(&tdmd->texture->id); + } +} + +static void freeData(ModifierData *md) +{ + DisplaceModifierData *dmd = (DisplaceModifierData *) md; + if (dmd->texture) { + id_us_min(&dmd->texture->id); + } } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) @@ -292,7 +305,7 @@ ModifierTypeInfo modifierType_Displace = { /* applyModifierEM */ NULL, /* initData */ initData, /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, + /* freeData */ freeData, /* isDisabled */ isDisabled, /* updateDepgraph */ updateDepgraph, /* dependsOnTime */ dependsOnTime, -- cgit v1.2.3