[Bf-blender-cvs] [7d1e429] id-remap: Attempt to fix the NodeTree issue.

Bastien Montagne noreply at git.blender.org
Thu Oct 8 20:38:17 CEST 2015


Commit: 7d1e429d7c0c2988282529780555de62dc55a33c
Author: Bastien Montagne
Date:   Thu Oct 8 20:35:47 2015 +0200
Branches: id-remap
https://developer.blender.org/rB7d1e429d7c0c2988282529780555de62dc55a33c

Attempt to fix the NodeTree issue.

So, idea is, since mat/tex/scene/etc. nodetrees are owned by their respective IDs
(those nodetree do not exist in Main, they are systematically freed with their ower IDs, etc.),
we should not treat them as IDs in IDlooper, but rather as mere sub-data, and hence directly
loop over the IDs of those nodetrees.

>From quick check it seems to work, but this needs to be confirmed as a valid idea!

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

M	source/blender/blenkernel/intern/library_query.c

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

diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index c3c79f0..753cdbc 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -224,7 +224,10 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 			CALLBACK_INVOKE(scene->world, IDWALK_USER);
 			CALLBACK_INVOKE(scene->set, IDWALK_NOP);
 			CALLBACK_INVOKE(scene->clip, IDWALK_NOP);
-			CALLBACK_INVOKE(scene->nodetree, IDWALK_NOP);
+			if (scene->nodetree) {
+				/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
+				BKE_library_foreach_ID_link((ID *)scene->nodetree, callback, user_data, flag);
+			}
 			if (scene->basact) {
 				CALLBACK_INVOKE(scene->basact->object, IDWALK_NOP);
 			}
@@ -429,7 +432,10 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 					library_foreach_mtex(&data, material->mtex[i]);
 				}
 			}
-			CALLBACK_INVOKE(material->nodetree, IDWALK_NOP);
+			if (material->nodetree) {
+				/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
+				BKE_library_foreach_ID_link((ID *)material->nodetree, callback, user_data, flag);
+			}
 			CALLBACK_INVOKE(material->group, IDWALK_USER);
 			break;
 		}
@@ -437,7 +443,10 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 		case ID_TE:
 		{
 			Tex *texture = (Tex *) id;
-			CALLBACK_INVOKE(texture->nodetree, IDWALK_NOP);
+			if (texture->nodetree) {
+				/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
+				BKE_library_foreach_ID_link((ID *)texture->nodetree, callback, user_data, flag);
+			}
 			CALLBACK_INVOKE(texture->ima, IDWALK_USER);
 			if (texture->env) {
 				CALLBACK_INVOKE(texture->env->object, IDWALK_NOP);
@@ -467,7 +476,10 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 					library_foreach_mtex(&data, lamp->mtex[i]);
 				}
 			}
-			CALLBACK_INVOKE(lamp->nodetree, IDWALK_NOP);
+			if (lamp->nodetree) {
+				/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
+				BKE_library_foreach_ID_link((ID *)lamp->nodetree, callback, user_data, flag);
+			}
 			break;
 		}
 
@@ -500,7 +512,10 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 					library_foreach_mtex(&data, world->mtex[i]);
 				}
 			}
-			CALLBACK_INVOKE(world->nodetree, IDWALK_NOP);
+			if (world->nodetree) {
+				/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
+				BKE_library_foreach_ID_link((ID *)world->nodetree, callback, user_data, flag);
+			}
 			break;
 		}
 
@@ -625,7 +640,10 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 					library_foreach_mtex(&data, linestyle->mtex[i]);
 				}
 			}
-			CALLBACK_INVOKE(linestyle->nodetree, IDWALK_NOP);
+			if (linestyle->nodetree) {
+				/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
+				BKE_library_foreach_ID_link((ID *)linestyle->nodetree, callback, user_data, flag);
+			}
 
 			for (lsm = linestyle->color_modifiers.first; lsm; lsm = lsm->next) {
 				if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {




More information about the Bf-blender-cvs mailing list