[Bf-blender-cvs] [1e18efa1df1] blender2.8: Fix T59220: Deleting object causes blender 2.8 to crash

Sergey Sharybin noreply at git.blender.org
Fri Dec 14 15:30:07 CET 2018


Commit: 1e18efa1df1ad999303143156e0742d97d4c86bb
Author: Sergey Sharybin
Date:   Fri Dec 14 14:53:29 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB1e18efa1df1ad999303143156e0742d97d4c86bb

Fix T59220: Deleting object causes blender 2.8 to crash

The issue was caused by a special code in node tree freeing function
which will free extra fields in the case when tree is not in bmain.
This is how old code was dealing with "nested" trees, but is now
making behavior different from other datablocks. This is exactly
what was confusing copy-on-write logic.

Ideally, ntreeFreeTree() need to behave same as all other datablocks,
ad freeing of data of nested trees should be up to the owner of the
tree (this way it's all explicit and does not depend on check of
some special flag.

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

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

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

diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 458d723c95a..70f3c6d6cf6 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -679,13 +679,19 @@ void BKE_libblock_relink_to_newid(ID *id)
 
 void BKE_libblock_free_data(ID *id, const bool do_id_user)
 {
+	/* NOTE: We set pointers to NULL so subsequent call of this function doesn't
+	 * cause double-free.
+	 * This is mainly to prevent crazy behavior of ntreeFreeTree() which does
+	 * call BKE_libblock_free_data() for nodetrees outside of bmain. */
 	if (id->properties) {
 		IDP_FreeProperty_ex(id->properties, do_id_user);
 		MEM_freeN(id->properties);
+		id->properties = NULL;
 	}
 
 	if (id->override_static) {
 		BKE_override_static_free(&id->override_static);
+		id->override_static = NULL;
 	}
 
 	/* XXX TODO remove animdata handling from each type's freeing func, and do it here, like for copy! */



More information about the Bf-blender-cvs mailing list