From 6d64da1e67e319e826450cefc1f6541b0fbb57e9 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Fri, 23 Aug 2019 15:50:53 +0200 Subject: Fix potential issues when loading files with missing libraries This is a continuation of rB39f005eae8eed8b939579aff8c9a05a4f50e5e38 Now all the fields where we check for object type in RNA (like rna_Curve_object_poll) will have a safe guard for when this isn't the case. For example when loading files that has missing object libraries and all missing objects are replaced with empties (placeholders). Reviewed By: Brecht Differential Revision: http://developer.blender.org/D5425 --- source/blender/modifiers/intern/MOD_mask.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/blender/modifiers/intern/MOD_mask.c') diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index f2f2b13b0df..bc218114432 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -344,6 +344,20 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes return result; } +static bool isDisabled(const struct Scene *UNUSED(scene), + ModifierData *md, + bool UNUSED(useRenderParams)) +{ + MaskModifierData *mmd = (MaskModifierData *)md; + + /* The object type check is only needed here in case we have a placeholder + * object assigned (because the library containing the armature is missing). + * + * In other cases it should be impossible to have a type missmatch. + */ + return mmd->ob_arm && mmd->ob_arm->type != OB_ARMATURE; +} + ModifierTypeInfo modifierType_Mask = { /* name */ "Mask", /* structName */ "MaskModifierData", @@ -363,7 +377,7 @@ ModifierTypeInfo modifierType_Mask = { /* initData */ NULL, /* requiredDataMask */ requiredDataMask, /* freeData */ NULL, - /* isDisabled */ NULL, + /* isDisabled */ isDisabled, /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* dependsOnNormals */ NULL, -- cgit v1.2.3