From 67a5d1b660a37a43f4d70fc7d588b67bef434574 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 10 Jun 2013 18:12:07 +0000 Subject: Follow up to r57354: WeightVG and Wave modifiers too need to handle tex id refcount ;) --- source/blender/modifiers/intern/MOD_wave.c | 17 +++++++++++++++-- source/blender/modifiers/intern/MOD_weightvgedit.c | 9 +++++++++ source/blender/modifiers/intern/MOD_weightvgmix.c | 15 ++++++++++++++- source/blender/modifiers/intern/MOD_weightvgproximity.c | 15 ++++++++++++++- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index bf5f9fb6ae9..8c6c483472e 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -43,9 +43,10 @@ #include "BLI_string.h" +#include "BKE_deform.h" #include "BKE_DerivedMesh.h" +#include "BKE_library.h" #include "BKE_object.h" -#include "BKE_deform.h" #include "BKE_scene.h" #include "depsgraph_private.h" @@ -77,6 +78,14 @@ static void initData(ModifierData *md) wmd->defgrp_name[0] = 0; } +static void freeData(ModifierData *md) +{ + WaveModifierData *wmd = (WaveModifierData *) md; + if (wmd->texture) { + id_us_min(&wmd->texture->id); + } +} + static void copyData(ModifierData *md, ModifierData *target) { WaveModifierData *wmd = (WaveModifierData *) md; @@ -98,6 +107,10 @@ static void copyData(ModifierData *md, ModifierData *target) twmd->map_object = wmd->map_object; twmd->texmapping = wmd->texmapping; BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name)); + + if (twmd->texture) { + id_us_plus(&twmd->texture->id); + } } static bool dependsOnTime(ModifierData *UNUSED(md)) @@ -378,7 +391,7 @@ ModifierTypeInfo modifierType_Wave = { /* applyModifierEM */ NULL, /* initData */ initData, /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, + /* freeData */ freeData, /* isDisabled */ NULL, /* updateDepgraph */ updateDepgraph, /* dependsOnTime */ dependsOnTime, diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index eee0856d69e..959e4d4f59d 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -43,6 +43,7 @@ #include "BKE_cdderivedmesh.h" #include "BKE_colortools.h" /* CurveMapping. */ #include "BKE_deform.h" +#include "BKE_library.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_texture.h" /* Texture masking. */ @@ -77,6 +78,10 @@ static void freeData(ModifierData *md) { WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; curvemapping_free(wmd->cmap_curve); + + if (wmd->mask_texture) { + id_us_min(&wmd->mask_texture->id); + } } static void copyData(ModifierData *md, ModifierData *target) @@ -102,6 +107,10 @@ static void copyData(ModifierData *md, ModifierData *target) twmd->mask_tex_mapping = wmd->mask_tex_mapping; twmd->mask_tex_map_obj = wmd->mask_tex_map_obj; BLI_strncpy(twmd->mask_tex_uvlayer_name, wmd->mask_tex_uvlayer_name, sizeof(twmd->mask_tex_uvlayer_name)); + + if (twmd->mask_texture) { + id_us_plus(&twmd->mask_texture->id); + } } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index a5843d04c24..1ec287b3b3a 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -39,6 +39,7 @@ #include "BKE_cdderivedmesh.h" #include "BKE_deform.h" +#include "BKE_library.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_texture.h" /* Texture masking. */ @@ -123,6 +124,14 @@ static void initData(ModifierData *md) wmd->mask_tex_mapping = MOD_DISP_MAP_LOCAL; } +static void freeData(ModifierData *md) +{ + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; + if (wmd->mask_texture) { + id_us_min(&wmd->mask_texture->id); + } +} + static void copyData(ModifierData *md, ModifierData *target) { WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; @@ -142,6 +151,10 @@ static void copyData(ModifierData *md, ModifierData *target) twmd->mask_tex_mapping = wmd->mask_tex_mapping; twmd->mask_tex_map_obj = wmd->mask_tex_map_obj; BLI_strncpy(twmd->mask_tex_uvlayer_name, wmd->mask_tex_uvlayer_name, sizeof(twmd->mask_tex_uvlayer_name)); + + if (twmd->mask_texture) { + id_us_plus(&twmd->mask_texture->id); + } } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) @@ -418,7 +431,7 @@ ModifierTypeInfo modifierType_WeightVGMix = { /* applyModifierEM */ NULL, /* initData */ initData, /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, + /* freeData */ freeData, /* isDisabled */ isDisabled, /* updateDepgraph */ updateDepgraph, /* dependsOnTime */ dependsOnTime, diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 7a9bb6b34d1..f0e9a26f10a 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -47,6 +47,7 @@ #include "BKE_cdderivedmesh.h" #include "BKE_deform.h" +#include "BKE_library.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_shrinkwrap.h" /* For SpaceTransform stuff. */ @@ -242,6 +243,14 @@ static void initData(ModifierData *md) wmd->max_dist = 1.0f; /* vert arbitrary distance, but don't use 0 */ } +static void freeData(ModifierData *md) +{ + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; + if (wmd->mask_texture) { + id_us_min(&wmd->mask_texture->id); + } +} + static void copyData(ModifierData *md, ModifierData *target) { WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; @@ -263,6 +272,10 @@ static void copyData(ModifierData *md, ModifierData *target) BLI_strncpy(twmd->mask_tex_uvlayer_name, wmd->mask_tex_uvlayer_name, sizeof(twmd->mask_tex_uvlayer_name)); twmd->min_dist = wmd->min_dist; twmd->max_dist = wmd->max_dist; + + if (twmd->mask_texture) { + id_us_plus(&twmd->mask_texture->id); + } } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) @@ -563,7 +576,7 @@ ModifierTypeInfo modifierType_WeightVGProximity = { /* applyModifierEM */ NULL, /* initData */ initData, /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, + /* freeData */ freeData, /* isDisabled */ isDisabled, /* updateDepgraph */ updateDepgraph, /* dependsOnTime */ dependsOnTime, -- cgit v1.2.3