diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-06-17 15:16:51 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-06-17 15:30:16 +0300 |
commit | 7f5c6834f8242e9d573420f65b4dd127e53002cf (patch) | |
tree | 90e95d03a0d69f2d7b8b4fbe2df8e98f37f0bafe /source/blender/blenloader | |
parent | b84085ef1a0a0b484177ad174b789296ad23b5ff (diff) |
Fix T63706: crash in files with custom node trees that contain builtin nodes
Don't make assumptions about which nodes exist in which node trees when loading.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 444d3c6a3d4..541ebe8f01d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3517,60 +3517,62 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) if (node->storage) { /* could be handlerized at some point */ - if (ntree->type == NTREE_SHADER) { - if (node->type == SH_NODE_CURVE_VEC || node->type == SH_NODE_CURVE_RGB) { + switch (node->type) { + case SH_NODE_CURVE_VEC: + case SH_NODE_CURVE_RGB: + case CMP_NODE_TIME: + case CMP_NODE_CURVE_VEC: + case CMP_NODE_CURVE_RGB: + case CMP_NODE_HUECORRECT: + case TEX_NODE_CURVE_RGB: + case TEX_NODE_CURVE_TIME: { direct_link_curvemapping(fd, node->storage); + break; } - else if (node->type == SH_NODE_SCRIPT) { + case SH_NODE_SCRIPT: { NodeShaderScript *nss = (NodeShaderScript *)node->storage; nss->bytecode = newdataadr(fd, nss->bytecode); + break; } - else if (node->type == SH_NODE_TEX_POINTDENSITY) { + case SH_NODE_TEX_POINTDENSITY: { NodeShaderTexPointDensity *npd = (NodeShaderTexPointDensity *)node->storage; memset(&npd->pd, 0, sizeof(npd->pd)); + break; } - else if (node->type == SH_NODE_TEX_IMAGE) { + case SH_NODE_TEX_IMAGE: { NodeTexImage *tex = (NodeTexImage *)node->storage; tex->iuser.ok = 1; tex->iuser.scene = NULL; + break; } - else if (node->type == SH_NODE_TEX_ENVIRONMENT) { + case SH_NODE_TEX_ENVIRONMENT: { NodeTexEnvironment *tex = (NodeTexEnvironment *)node->storage; tex->iuser.ok = 1; tex->iuser.scene = NULL; + break; } - } - else if (ntree->type == NTREE_COMPOSIT) { - if (ELEM(node->type, - CMP_NODE_TIME, - CMP_NODE_CURVE_VEC, - CMP_NODE_CURVE_RGB, - CMP_NODE_HUECORRECT)) { - direct_link_curvemapping(fd, node->storage); - } - else if (ELEM(node->type, - CMP_NODE_IMAGE, - CMP_NODE_R_LAYERS, - CMP_NODE_VIEWER, - CMP_NODE_SPLITVIEWER)) { + case CMP_NODE_IMAGE: + case CMP_NODE_R_LAYERS: + case CMP_NODE_VIEWER: + case CMP_NODE_SPLITVIEWER: { ImageUser *iuser = node->storage; iuser->ok = 1; iuser->scene = NULL; + break; } - else if (node->type == CMP_NODE_CRYPTOMATTE) { + case CMP_NODE_CRYPTOMATTE: { NodeCryptomatte *nc = (NodeCryptomatte *)node->storage; nc->matte_id = newdataadr(fd, nc->matte_id); + break; } - } - else if (ntree->type == NTREE_TEXTURE) { - if (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME) { - direct_link_curvemapping(fd, node->storage); - } - else if (node->type == TEX_NODE_IMAGE) { + case TEX_NODE_IMAGE: { ImageUser *iuser = node->storage; iuser->ok = 1; iuser->scene = NULL; + break; } + default: + break; } } } |