[Bf-blender-cvs] [3c73691] master: Fix T47379: crash appending materials with node trees.

Brecht Van Lommel noreply at git.blender.org
Thu Feb 11 22:38:21 CET 2016


Commit: 3c7369164e0a7edc858b45298bae25c0a20ed0f8
Author: Brecht Van Lommel
Date:   Thu Feb 11 22:32:11 2016 +0100
Branches: master
https://developer.blender.org/rB3c7369164e0a7edc858b45298bae25c0a20ed0f8

Fix T47379: crash appending materials with node trees.

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

M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/node.c

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

diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 9c5e5e5..62c5fc9 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -85,6 +85,7 @@ void id_sort_by_name(struct ListBase *lb, struct ID *id);
 
 bool new_id(struct ListBase *lb, struct ID *id, const char *name);
 void id_clear_lib_data(struct Main *bmain, struct ID *id);
+void id_clear_lib_data_ex(struct Main *bmain, struct ID *id, bool id_in_mainlist);
 
 struct ListBase *which_libbase(struct Main *mainlib, short type);
 
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 5d03a42..2ece0f7 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -347,7 +347,7 @@ void              ntreeUserDecrefID(struct bNodeTree *ntree);
 
 struct bNodeTree *ntreeFromID(struct ID *id);
 
-void              ntreeMakeLocal(struct bNodeTree *ntree);
+void              ntreeMakeLocal(struct bNodeTree *ntree, bool id_in_mainlist);
 bool              ntreeHasType(const struct bNodeTree *ntree, int type);
 bool              ntreeHasTree(const struct bNodeTree *ntree, const struct bNodeTree *lookup);
 void              ntreeUpdateTree(struct Main *main, struct bNodeTree *ntree);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 67b6661..c460320 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -323,7 +323,7 @@ bool id_make_local(ID *id, bool test)
 			if (!test) BKE_action_make_local((bAction *)id);
 			return true;
 		case ID_NT:
-			if (!test) ntreeMakeLocal((bNodeTree *)id);
+			if (!test) ntreeMakeLocal((bNodeTree *)id, true);
 			return true;
 		case ID_BR:
 			if (!test) BKE_brush_make_local((Brush *)id);
@@ -1654,7 +1654,7 @@ bool new_id(ListBase *lb, ID *id, const char *tname)
  * Pull an ID out of a library (make it local). Only call this for IDs that
  * don't have other library users.
  */
-void id_clear_lib_data(Main *bmain, ID *id)
+void id_clear_lib_data_ex(Main *bmain, ID *id, bool id_in_mainlist)
 {
 	bNodeTree *ntree = NULL;
 
@@ -1664,7 +1664,8 @@ void id_clear_lib_data(Main *bmain, ID *id)
 
 	id->lib = NULL;
 	id->tag &= ~(LIB_TAG_INDIRECT | LIB_TAG_EXTERN);
-	new_id(which_libbase(bmain, GS(id->name)), id, NULL);
+	if (id_in_mainlist)
+		new_id(which_libbase(bmain, GS(id->name)), id, NULL);
 
 	/* internal bNodeTree blocks inside ID types below
 	 * also stores id->lib, make sure this stays in sync.
@@ -1672,7 +1673,7 @@ void id_clear_lib_data(Main *bmain, ID *id)
 	ntree = ntreeFromID(id);
 
 	if (ntree) {
-		ntreeMakeLocal(ntree);
+		ntreeMakeLocal(ntree, false);
 	}
 
 	if (GS(id->name) == ID_OB) {
@@ -1685,6 +1686,11 @@ void id_clear_lib_data(Main *bmain, ID *id)
 	}
 }
 
+void id_clear_lib_data(Main *bmain, ID *id)
+{
+	id_clear_lib_data_ex(bmain, id, true);
+}
+
 /* next to indirect usage in read/writefile also in editobject.c scene.c */
 void BKE_main_id_clear_newpoins(Main *bmain)
 {
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index ad714b8..bc8a7d9 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1979,7 +1979,7 @@ static void extern_local_ntree(bNodeTree *ntree)
 	}
 }
 
-void ntreeMakeLocal(bNodeTree *ntree)
+void ntreeMakeLocal(bNodeTree *ntree, bool id_in_mainlist)
 {
 	Main *bmain = G.main;
 	bool lib = false, local = false;
@@ -1991,7 +1991,7 @@ void ntreeMakeLocal(bNodeTree *ntree)
 	
 	if (ntree->id.lib == NULL) return;
 	if (ntree->id.us == 1) {
-		id_clear_lib_data(bmain, (ID *)ntree);
+		id_clear_lib_data_ex(bmain, (ID *)ntree, id_in_mainlist);
 		extern_local_ntree(ntree);
 		return;
 	}
@@ -2012,7 +2012,7 @@ void ntreeMakeLocal(bNodeTree *ntree)
 	
 	/* if all users are local, we simply make tree local */
 	if (local && !lib) {
-		id_clear_lib_data(bmain, (ID *)ntree);
+		id_clear_lib_data_ex(bmain, (ID *)ntree, id_in_mainlist);
 		extern_local_ntree(ntree);
 	}
 	else if (local && lib) {




More information about the Bf-blender-cvs mailing list