Bug fix #34436
authorTon Roosendaal <ton@blender.org>
Wed, 27 Feb 2013 14:25:39 +0000 (14:25 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 27 Feb 2013 14:25:39 +0000 (14:25 +0000)
Two example files that crashed texture nodes.
- On delete texture nodes, it should free the exec cache (because this cache
  stores the node pointer.
- On redo, nodes can exist can exist without typeinfo set. Exec (free) code
  was not checking for that. Don't ask me why this happens... tex nodes are weird.

source/blender/blenkernel/intern/node.c
source/blender/nodes/intern/node_exec.c

index 86fe472..3dbaab0 100644 (file)
@@ -991,6 +991,12 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
 
                if (treetype->free_node_cache)
                        treetype->free_node_cache(ntree, node);
+               
+               /* texture node has bad habit of keeping exec data around */
+               if (ntree->type == NTREE_TEXTURE && ntree->execdata) {
+                       ntreeTexEndExecTree(ntree->execdata, 1);
+                       ntree->execdata = NULL;
+               }
        }
        
        /* since it is called while free database, node->id is undefined */
@@ -1040,6 +1046,7 @@ void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user)
                                break;
                        case NTREE_TEXTURE:
                                ntreeTexEndExecTree(ntree->execdata, 1);
+                               ntree->execdata = NULL;
                                break;
                }
        }
index 7a8b8c9..8cf7cc7 100644 (file)
@@ -248,8 +248,9 @@ void ntree_exec_end(bNodeTreeExec *exec)
                MEM_freeN(exec->stack);
        
        for (n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
-               if (nodeexec->node->typeinfo->freeexecfunc)
-                       nodeexec->node->typeinfo->freeexecfunc(nodeexec->node, nodeexec->data);
+               if (nodeexec->node->typeinfo)
+                       if (nodeexec->node->typeinfo->freeexecfunc)
+                               nodeexec->node->typeinfo->freeexecfunc(nodeexec->node, nodeexec->data);
        }
        
        if (exec->nodeexec)