Bugfix #25525
authorTon Roosendaal <ton@blender.org>
Sat, 8 Jan 2011 19:12:42 +0000 (19:12 +0000)
committerTon Roosendaal <ton@blender.org>
Sat, 8 Jan 2011 19:12:42 +0000 (19:12 +0000)
Duplicating viewer node crashed in cases; bad ID was given to a function.
Fix provided by Alexander Kuznetsov. Thanks!

source/blender/editors/space_node/node_edit.c

index 6a6c7c6..dc2396f 100644 (file)
@@ -330,6 +330,7 @@ void ED_node_texture_default(Tex *tx)
        ntreeSolveOrder(tx->nodetree);  /* needed for pointers */
 }
 
+/* id is supposed to contain a node tree */
 void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype)
 {
        bNode *node= NULL;
@@ -347,6 +348,10 @@ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *tre
                *ntree= ((Tex*)id)->nodetree;
                if(treetype) *treetype= NTREE_TEXTURE;
        }
+       else {
+               if(treetype) *treetype= 0;
+               return;
+       }
 
        /* find editable group */
        if(edittree) {
@@ -1521,7 +1526,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
        for(node= snode->edittree->nodes.first; node; node= node->next)
                if(node->flag & SELECT)
                        if(node->id)
-                               ED_node_changed_update(node->id, node);
+                               ED_node_changed_update(snode->id, node);
        
        ntreeSolveOrder(snode->edittree);
        node_tree_verify_groups(snode->nodetree);