[Bf-blender-cvs] [a6585fa4b1a] master: Cleanup: moar removal of G.main in BKE area...

Bastien Montagne noreply at git.blender.org
Tue Jun 12 15:17:15 CEST 2018


Commit: a6585fa4b1a7a4dd4b5ea21efcee36c8460ff5ec
Author: Bastien Montagne
Date:   Tue Jun 12 15:16:45 2018 +0200
Branches: master
https://developer.blender.org/rBa6585fa4b1a7a4dd4b5ea21efcee36c8460ff5ec

Cleanup: moar removal of G.main in BKE area...

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

M	source/blender/blenkernel/BKE_group.h
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/group.c
M	source/blender/blenkernel/intern/library_remap.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/object/object_group.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/physics/rigidbody_constraint.c
M	source/blender/editors/physics/rigidbody_object.c
M	source/blender/makesrna/intern/rna_group.c

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

diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h
index 9e1ad1bc789..9824814990f 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -46,8 +46,9 @@ void          BKE_group_copy_data(struct Main *bmain, struct Group *group_dst, c
 struct Group *BKE_group_copy(struct Main *bmain, const struct Group *group);
 void          BKE_group_make_local(struct Main *bmain, struct Group *group, const bool lib_local);
 bool          BKE_group_object_add(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
-bool          BKE_group_object_unlink(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
-struct Group *BKE_group_object_find(struct Group *group, struct Object *ob);
+bool          BKE_group_object_unlink(
+        struct Main *bmain, struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
+struct Group *BKE_group_object_find(struct Main *bmain, struct Group *group, struct Object *ob);
 bool          BKE_group_object_exists(struct Group *group, struct Object *ob);
 bool          BKE_group_object_cyclic_check(struct Main *bmain, struct Object *object, struct Group *group);
 bool          BKE_group_is_animated(struct Group *group, struct Object *parent);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 51cfc5b0087..677d6b3fba2 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -283,8 +283,9 @@ typedef enum eObjectSet {
 
 struct LinkNode *BKE_object_relational_superset(
         struct Scene *scene, eObjectSet objectSet, eObRelationTypes includeFilter);
-struct LinkNode *BKE_object_groups(struct Object *ob);
-void             BKE_object_groups_clear(struct Scene *scene, struct Base *base, struct Object *object);
+struct LinkNode *BKE_object_groups(struct Main *bmain, struct Object *ob);
+void             BKE_object_groups_clear(
+        struct Main *bmain, struct Scene *scene, struct Base *base, struct Object *object);
 
 struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
 
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 578aa97c255..f268c419e2f 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -223,11 +223,11 @@ bool BKE_group_object_cyclic_check(Main *bmain, Object *object, Group *group)
 	return group_object_cyclic_check_internal(object, group);
 }
 
-bool BKE_group_object_unlink(Group *group, Object *object, Scene *scene, Base *base)
+bool BKE_group_object_unlink(Main *bmain, Group *group, Object *object, Scene *scene, Base *base)
 {
 	if (group_object_unlink_internal(group, object)) {
 		/* object can be NULL */
-		if (object && BKE_group_object_find(NULL, object) == NULL) {
+		if (object && BKE_group_object_find(bmain, NULL, object) == NULL) {
 			if (scene && base == NULL)
 				base = BKE_scene_base_find(scene, object);
 
@@ -253,12 +253,12 @@ bool BKE_group_object_exists(Group *group, Object *ob)
 	}
 }
 
-Group *BKE_group_object_find(Group *group, Object *ob)
+Group *BKE_group_object_find(Main *bmain, Group *group, Object *ob)
 {
 	if (group)
 		group = group->id.next;
 	else
-		group = G.main->group.first;
+		group = bmain->group.first;
 	
 	while (group) {
 		if (BKE_group_object_exists(group, ob))
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 8a64c0f8662..2a70e53be92 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -335,12 +335,12 @@ static void libblock_remap_data_postprocess_object_update(Main *bmain, Object *o
 		 *     - unlinked old_ob (i.e. new_ob is NULL), in which case scenes' bases have been removed already.
 		 *     - remapped old_ob by new_ob, in which case scenes' bases are still valid as is.
 		 * So in any case, no need to update them here. */
-		if (BKE_group_object_find(NULL, old_ob) == NULL) {
+		if (BKE_group_object_find(bmain, NULL, old_ob) == NULL) {
 			old_ob->flag &= ~OB_FROMGROUP;
 		}
 		if (new_ob == NULL) {  /* We need to remove NULL-ified groupobjects... */
 			for (Group *group = bmain->group.first; group; group = group->id.next) {
-				BKE_group_object_unlink(group, NULL, NULL, NULL);
+				BKE_group_object_unlink(bmain, group, NULL, NULL, NULL);
 			}
 		}
 		else {
@@ -356,7 +356,7 @@ static void libblock_remap_data_postprocess_object_update(Main *bmain, Object *o
 	}
 }
 
-static void libblock_remap_data_postprocess_group_scene_unlink(Main *UNUSED(bmain), Scene *sce, ID *old_id)
+static void libblock_remap_data_postprocess_group_scene_unlink(Main *bmain, Scene *sce, ID *old_id)
 {
 	/* Note that here we assume no object has no base (i.e. all objects are assumed instanced
 	 * in one scene...). */
@@ -365,11 +365,11 @@ static void libblock_remap_data_postprocess_group_scene_unlink(Main *UNUSED(bmai
 			Object *ob = base->object;
 
 			if (ob->flag & OB_FROMGROUP) {
-				Group *grp = BKE_group_object_find(NULL, ob);
+				Group *grp = BKE_group_object_find(bmain, NULL, ob);
 
 				/* Unlinked group (old_id) is still in bmain... */
 				if (grp && (&grp->id == old_id || grp->id.us == 0)) {
-					grp = BKE_group_object_find(grp, ob);
+					grp = BKE_group_object_find(bmain, grp, ob);
 				}
 				if (!grp) {
 					ob->flag &= ~OB_FROMGROUP;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 9178b889062..1944b01827b 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3384,18 +3384,18 @@ LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet objectS
 /**
  * return all groups this object is apart of, caller must free.
  */
-struct LinkNode *BKE_object_groups(Object *ob)
+struct LinkNode *BKE_object_groups(Main *bmain, Object *ob)
 {
 	LinkNode *group_linknode = NULL;
 	Group *group = NULL;
-	while ((group = BKE_group_object_find(group, ob))) {
+	while ((group = BKE_group_object_find(bmain, group, ob))) {
 		BLI_linklist_prepend(&group_linknode, group);
 	}
 
 	return group_linknode;
 }
 
-void BKE_object_groups_clear(Scene *scene, Base *base, Object *object)
+void BKE_object_groups_clear(Main *bmain, Scene *scene, Base *base, Object *object)
 {
 	Group *group = NULL;
 
@@ -3405,8 +3405,8 @@ void BKE_object_groups_clear(Scene *scene, Base *base, Object *object)
 		base = BKE_scene_base_find(scene, object);
 	}
 
-	while ((group = BKE_group_object_find(group, base->object))) {
-		BKE_group_object_unlink(group, object, scene, base);
+	while ((group = BKE_group_object_find(bmain, group, base->object))) {
+		BKE_group_object_unlink(bmain, group, object, scene, base);
 	}
 }
 
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 97d2280c021..4201bf3d3fb 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -581,7 +581,7 @@ static const DupliGenerator gen_dupli_verts = {
 };
 
 /* OB_DUPLIVERTS - FONT */
-static Object *find_family_object(const char *family, size_t family_len, unsigned int ch, GHash *family_gh)
+static Object *find_family_object(Main *bmain, const char *family, size_t family_len, unsigned int ch, GHash *family_gh)
 {
 	Object **ob_pt;
 	Object *ob;
@@ -598,7 +598,7 @@ static Object *find_family_object(const char *family, size_t family_len, unsigne
 		ch_utf8[ch_utf8_len] = '\0';
 		ch_utf8_len += 1;  /* compare with null terminator */
 
-		for (ob = G.main->object.first; ob; ob = ob->id.next) {
+		for (ob = bmain->object.first; ob; ob = ob->id.next) {
 			if (STREQLEN(ob->id.name + 2 + family_len, ch_utf8, ch_utf8_len)) {
 				if (STREQLEN(ob->id.name + 2, family, family_len)) {
 					break;
@@ -655,7 +655,7 @@ static void make_duplis_font(const DupliContext *ctx)
 	/* advance matching BLI_strncpy_wchar_from_utf8 */
 	for (a = 0; a < text_len; a++, ct++) {
 
-		ob = find_family_object(cu->family, family_len, (unsigned int)text[a], family_gh);
+		ob = find_family_object(ctx->bmain, cu->family, family_len, (unsigned int)text[a], family_gh);
 		if (ob) {
 			vec[0] = fsize * (ct->xof - xof);
 			vec[1] = fsize * (ct->yof - yof);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4df79250125..d172dd685eb 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7582,9 +7582,9 @@ static void direct_link_group(FileData *fd, Group *group)
 	group->preview = direct_link_preview_image(fd, group->preview);
 }
 
-static void lib_link_group(FileData *fd, Main *main)
+static void lib_link_group(FileData *fd, Main *bmain)
 {
-	for (Group *group = main->group.first; group; group = group->id.next) {
+	for (Group *group = bmain->group.first; group; group = group->id.next) {
 		if (group->id.tag & LIB_TAG_NEED_LINK) {
 			IDP_LibLinkProperty(group->id.properties, fd);
 			
@@ -7601,7 +7601,7 @@ static void lib_link_group(FileData *fd, Main *main)
 			if (add_us) {
 				id_us_ensure_real(&group->id);
 			}
-			BKE_group_object_unlink(group, NULL, NULL, NULL);	/* removes NULL entries */
+			BKE_group_object_unlink(bmain, group, NULL, NULL, NULL);	/* removes NULL entries */
 
 			group->id.tag &= ~LIB_TAG_NEED_LINK;
 		}
diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c
index e5accee171a..c764ee22162 100644
--- a/source/blender/editors/object/object_group.c
+++ b/source/blender/editors/object/object_group.c
@@ -65,6 +65,7 @@
 /* can be called with C == NULL */
 static const EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
 {
+	Main *bmain = CTX_data_main(C);
 	Object *ob;
 	EnumPropertyItem *item = NULL, item_tmp = {0};
 	int totitem = 0;
@@ -82,7 +83,7 @@ static const EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA
 
 		/* if 2 or more groups, add option to add to all groups */
 		group = NULL;
-	

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list