[Bf-blender-cvs] [18ecc8a] master: Fix broken groupobject usercount handling.

Bastien Montagne noreply at git.blender.org
Mon Nov 9 15:24:23 CET 2015


Commit: 18ecc8a78f9eba45e513f7903989ef88cffbdb54
Author: Bastien Montagne
Date:   Mon Nov 9 14:44:53 2015 +0100
Branches: master
https://developer.blender.org/rB18ecc8a78f9eba45e513f7903989ef88cffbdb54

Fix broken groupobject usercount handling.

As we can see in (original) read code, ob pointer in groupobject is actually a 'USER_ONE' case.
This was not done in 'add object to group' code, probably because we can assume objects always
have at least one user in that case? Made it explicit now. Also fixed foreach_ID_link looper.

In general we have waaayyyyyy too much 'own handling' of ID->us count in code currently,
will clean up that...

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

M	source/blender/blenkernel/intern/group.c
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 1502265..96cf0fe 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -182,6 +182,7 @@ static bool group_object_add_internal(Group *group, Object *ob)
 	BLI_addtail(&group->gobject, go);
 	
 	go->ob = ob;
+	id_us_ensure_real(&go->ob->id);
 	
 	return true;
 }
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index a800b3d..002007e 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -514,7 +514,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 			Group *group = (Group *) id;
 			GroupObject *gob;
 			for (gob = group->gobject.first; gob; gob = gob->next) {
-				CALLBACK_INVOKE(gob->ob, IDWALK_NOP);
+				CALLBACK_INVOKE(gob->ob, IDWALK_USER_ONE);
 			}
 			break;
 		}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2060894..6c6af2d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7268,25 +7268,26 @@ static void lib_link_group(FileData *fd, Main *main)
 {
 	Group *group;
 	GroupObject *go;
-	int add_us;
+	bool add_us;
 	
 	for (group = main->group.first; group; group = group->id.next) {
 		if (group->id.flag & LIB_NEED_LINK) {
 			group->id.flag -= LIB_NEED_LINK;
 			
-			add_us = 0;
+			add_us = false;
 			
 			for (go = group->gobject.first; go; go = go->next) {
 				go->ob= newlibadr(fd, group->id.lib, go->ob);
 				if (go->ob) {
 					go->ob->flag |= OB_FROMGROUP;
 					/* if group has an object, it increments user... */
-					add_us = 1;
-					if (go->ob->id.us == 0)
-						go->ob->id.us = 1;
+					add_us = true;
+					id_us_ensure_real(&go->ob->id);
 				}
 			}
-			if (add_us) group->id.us++;
+			if (add_us) {
+				id_us_ensure_real(&group->id);
+			}
 			BKE_group_object_unlink(group, NULL, NULL, NULL);	/* removes NULL entries */
 		}
 	}




More information about the Bf-blender-cvs mailing list