[Bf-blender-cvs] [7853ebc2042] master: Fix collada importer doing own handling of usercount/freeing.

Bastien Montagne noreply at git.blender.org
Thu Jun 15 15:49:18 CEST 2017


Commit: 7853ebc204238a660b57431cd86ae113ae58c3a0
Author: Bastien Montagne
Date:   Thu Jun 15 12:44:15 2017 +0200
Branches: master
https://developer.blender.org/rB7853ebc204238a660b57431cd86ae113ae58c3a0

Fix collada importer doing own handling of usercount/freeing.

Better use generic `BKE_libblock_free_us()`.

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

M	source/blender/collada/DocumentImporter.cpp
M	source/blender/collada/MeshImporter.cpp

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

diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 226f319cefd..435eaa0208a 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -388,9 +388,7 @@ Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
 	Camera *cam = uid_camera_map[cam_uid];
 	Camera *old_cam = (Camera *)ob->data;
 	ob->data = cam;
-	id_us_min(&old_cam->id);
-	if (old_cam->id.us == 0)
-		BKE_libblock_free(G.main, old_cam);
+	BKE_libblock_free_us(G.main, old_cam);
 	return ob;
 }
 
@@ -406,9 +404,7 @@ Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce
 	Lamp *la = uid_lamp_map[lamp_uid];
 	Lamp *old_lamp = (Lamp *)ob->data;
 	ob->data = la;
-	id_us_min(&old_lamp->id);
-	if (old_lamp->id.us == 0)
-		BKE_libblock_free(G.main, old_lamp);
+	BKE_libblock_free_us(G.main, old_lamp);
 	return ob;
 }
 
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index a1bfce88131..6ca53c64299 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -1173,8 +1173,9 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
 	BKE_mesh_assign_object(ob, new_mesh);
 	BKE_mesh_calc_normals(new_mesh);
 
-	if (old_mesh->id.us == 0) BKE_libblock_free(G.main, old_mesh);
-	
+	id_us_plus(&old_mesh->id);  /* Because BKE_mesh_assign_object would have already decreased it... */
+	BKE_libblock_free_us(G.main, old_mesh);
+
 	char layername[100];
 	layername[0] = '\0';
 	MTFace *texture_face = NULL;




More information about the Bf-blender-cvs mailing list