[Bf-blender-cvs] [3d013f7b10b] blender2.8: Fix for assert failure in material preview

Sergey Sharybin noreply at git.blender.org
Tue Dec 4 12:31:41 CET 2018


Commit: 3d013f7b10b6837ab29eccf9a203477e13d278a2
Author: Sergey Sharybin
Date:   Tue Dec 4 12:30:24 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB3d013f7b10b6837ab29eccf9a203477e13d278a2

Fix for assert failure in material preview

All localized datablocks are not supposed to have animation
data associated with them.

There was an easy way to reproduce assert failure: toggle
animation decorator for Viewport Display -> Color.

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

M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/intern/lamp.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/material.c
M	source/blender/blenkernel/intern/texture.c
M	source/blender/blenkernel/intern/world.c

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

diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 038e9377ba4..a4eb40cbb38 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -93,6 +93,8 @@ void BKE_libblock_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r
 void *BKE_libblock_copy(struct Main *bmain, const struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 /* "Deprecated" old API. */
 void *BKE_libblock_copy_nolib(const struct ID *id, const bool do_action) ATTR_NONNULL();
+/* Special version. sued by datablock localization. */
+void *BKE_libblock_copy_for_localize(const struct ID *id);
 
 void  BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
 void  BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 681ff3b619f..29f62519350 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -150,7 +150,7 @@ Lamp *BKE_lamp_localize(Lamp *la)
 	 *
 	 * NOTE: Only possible once nested node trees are fully converted to that too. */
 
-	Lamp *lan = BKE_libblock_copy_nolib(&la->id, false);
+	Lamp *lan = BKE_libblock_copy_for_localize(&la->id);
 
 	lan->curfalloff = curvemapping_copy(la->curfalloff);
 
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index aa6cbcc343e..a76ac02e06f 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1362,6 +1362,16 @@ void *BKE_libblock_copy_nolib(const ID *id, const bool do_action)
 	return idn;
 }
 
+void *BKE_libblock_copy_for_localize(const ID *id)
+{
+	ID *idn;
+	BKE_libblock_copy_ex(NULL, id, &idn, (LIB_ID_CREATE_NO_MAIN |
+	                                      LIB_ID_CREATE_NO_USER_REFCOUNT |
+	                                      LIB_ID_COPY_ACTIONS |
+	                                      LIB_ID_COPY_NO_ANIMDATA));
+	return idn;
+}
+
 void BKE_library_free(Library *lib)
 {
 	if (lib->packedfile)
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 6741ebf39d2..d45b19bc0bf 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -235,7 +235,7 @@ Material *BKE_material_localize(Material *ma)
 	 *
 	 * NOTE: Only possible once nested node trees are fully converted to that too. */
 
-	Material *man = BKE_libblock_copy_nolib(&ma->id, false);
+	Material *man = BKE_libblock_copy_for_localize(&ma->id);
 
 	man->texpaintslot = NULL;
 	man->preview = NULL;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 5031b2de462..bd527ed8a44 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -476,7 +476,7 @@ Tex *BKE_texture_localize(Tex *tex)
 
 	Tex *texn;
 
-	texn = BKE_libblock_copy_nolib(&tex->id, false);
+	texn = BKE_libblock_copy_for_localize(&tex->id);
 
 	/* image texture: BKE_texture_free also doesn't decrease */
 
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index f4c32987117..e7a4167087b 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -154,7 +154,7 @@ World *BKE_world_localize(World *wrld)
 
 	World *wrldn;
 
-	wrldn = BKE_libblock_copy_nolib(&wrld->id, false);
+	wrldn = BKE_libblock_copy_for_localize(&wrld->id);
 
 	if (wrld->nodetree)
 		wrldn->nodetree = ntreeLocalize(wrld->nodetree);



More information about the Bf-blender-cvs mailing list