[Bf-blender-cvs] [884693b] master: Fix Node space ID remap callback not handling node trees.

Bastien Montagne noreply at git.blender.org
Fri Nov 18 22:44:21 CET 2016


Commit: 884693b42ae1d630349727519f6868b94f448643
Author: Bastien Montagne
Date:   Fri Nov 18 22:36:52 2016 +0100
Branches: master
https://developer.blender.org/rB884693b42ae1d630349727519f6868b94f448643

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.

===================================================================

M	source/blender/editors/space_node/space_node.c

===================================================================

diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 4ef703c..bbdf6fe 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 */




More information about the Bf-blender-cvs mailing list