Fix T40033: Jumping between versions can lead to loss of node storage

data.

Saving a file with a new blender node that uses bNode->storage data and
then loading that in an older version will make the node undefined, but
still retain the original type identifier (in case it is defined later).

If the file is then saved over and loaded again in the newer version,
where the node type is defined, it won't have a valid storage struct.
To handle such cases gracefully, check if storage data is expected but
doesn't exist when initializing node types. User then at least get a
chance of fixing the problem manually.

Suggested fix by @brecht.
This commit is contained in:
2014-05-07 11:42:38 +02:00
parent a8dddca0fe
commit 79c345acc2

View File

@@ -172,6 +172,12 @@ static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo)
static void node_set_typeinfo(const struct bContext *C, bNodeTree *ntree, bNode *node, bNodeType *typeinfo)
{
/* for nodes saved in older versions storage can get lost, make undefined then */
if (node->flag & NODE_INIT) {
if (typeinfo->storagename[0] && !node->storage)
typeinfo = NULL;
}
if (typeinfo) {
node->typeinfo = typeinfo;