From 884693b42ae1d630349727519f6868b94f448643 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 22:36:52 +0100 Subject: Fix Node space ID remap callback not handling node trees. Yep. Kinda ridiculous, but forgot to handle the very node trees data-blocks in that editor! Related (but not fixing) to T49991. --- source/blender/editors/space_node/space_node.c | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'source/blender/editors/space_node') diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 4ef703c8994..bbdf6feef01 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -855,6 +855,42 @@ static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID id_us_plus(new_id); } } + else if (GS(old_id->name) == ID_NT) { + bNodeTreePath *path, *path_next; + + for (path = snode->treepath.first; path; path = path->next) { + if ((ID *)path->nodetree == old_id) { + path->nodetree = (bNodeTree *)new_id; + id_us_min(old_id); + id_us_plus(new_id); + } + if (path == snode->treepath.first) { + /* first nodetree in path is same as snode->nodetree */ + snode->nodetree = path->nodetree; + } + if (path->nodetree == NULL) { + break; + } + } + + /* remaining path entries are invalid, remove */ + for (; path; path = path_next) { + path_next = path->next; + + BLI_remlink(&snode->treepath, path); + MEM_freeN(path); + } + + /* edittree is just the last in the path, + * set this directly since the path may have been shortened above */ + if (snode->treepath.last) { + path = snode->treepath.last; + snode->edittree = path->nodetree; + } + else { + snode->edittree = NULL; + } + } } /* only called once, from space/spacetypes.c */ -- cgit v1.2.3