Fix forward-compat Nodes write code being executed also for undo steps writing.

Forward compatibility code should never, ever be run during undo saving.

Note: related to T49991 (but does not fix it either, crash now happens
when doing a real file save...).
This commit is contained in:
Bastien Montagne 2016-11-18 22:41:56 +01:00
parent 884693b42a
commit 5a6534a5bb
1 changed files with 14 additions and 12 deletions

View File

@ -914,20 +914,22 @@ static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
static void write_node_socket(WriteData *wd, bNodeTree *UNUSED(ntree), bNode *node, bNodeSocket *sock)
{
#ifdef USE_NODE_COMPAT_CUSTOMNODES
/* forward compatibility code, so older blenders still open */
sock->stack_type = 1;
/* forward compatibility code, so older blenders still open (not for undo) */
if (wd->current == NULL) {
sock->stack_type = 1;
if (node->type == NODE_GROUP) {
bNodeTree *ngroup = (bNodeTree *)node->id;
if (ngroup) {
/* for node groups: look up the deprecated groupsock pointer */
sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier);
BLI_assert(sock->groupsock != NULL);
if (node->type == NODE_GROUP) {
bNodeTree *ngroup = (bNodeTree *)node->id;
if (ngroup) {
/* for node groups: look up the deprecated groupsock pointer */
sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier);
BLI_assert(sock->groupsock != NULL);
/* node group sockets now use the generic identifier string to verify group nodes,
* old blender uses the own_index.
*/
sock->own_index = sock->groupsock->own_index;
/* node group sockets now use the generic identifier string to verify group nodes,
* old blender uses the own_index.
*/
sock->own_index = sock->groupsock->own_index;
}
}
}
#endif