[Bf-blender-cvs] [d617a6c85b4] master: Cleanup/simplify G.main usages.

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


Commit: d617a6c85b4874a81d86568d00b56f2bda11c4b4
Author: Bastien Montagne
Date:   Tue Jun 12 15:03:51 2018 +0200
Branches: master
https://developer.blender.org/rBd617a6c85b4874a81d86568d00b56f2bda11c4b4

Cleanup/simplify G.main usages.

Using G.main only to get main bled filepath, or built-in fonts, is OK.
So now using the 'valid' G_MAIN macro here instead.

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

M	source/blender/blenkernel/BKE_font.h
M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/displist.c
M	source/blender/blenkernel/intern/font.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/editors/curve/editfont.c
M	source/blender/editors/object/object_add.c

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

diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index e5eea4423c9..bb1f97e83e6 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -86,13 +86,13 @@ struct VFont *BKE_vfont_load_exists(struct Main *bmain, const char *filepath);
 
 void BKE_vfont_make_local(struct Main *bmain, struct VFont *vfont, const bool lib_local);
 
-bool BKE_vfont_to_curve_ex(struct Main *bmain, struct Object *ob, struct Curve *cu, int mode,
+bool BKE_vfont_to_curve_ex(struct Object *ob, struct Curve *cu, int mode,
                            struct ListBase *r_nubase,
                            const wchar_t **r_text, int *r_text_len, bool *r_text_free,
                            struct CharTrans **r_chartransdata);
-bool BKE_vfont_to_curve_nubase(struct Main *bmain, struct Object *ob, int mode,
+bool BKE_vfont_to_curve_nubase(struct Object *ob, int mode,
                                struct ListBase *r_nubase);
-bool BKE_vfont_to_curve(struct Main *bmain, struct Object *ob, int mode);
+bool BKE_vfont_to_curve(struct Object *ob, int mode);
 
 int BKE_vfont_select_get(struct Object *ob, int *r_start, int *r_end);
 void BKE_vfont_select_clamp(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 943cab0a9fc..d89e7a12644 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -4959,7 +4959,7 @@ bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3])
 	 */
 	if (is_font) {
 		nurb_lb = &temp_nurb_lb;
-		BKE_vfont_to_curve_ex(G.main, NULL, cu, FO_EDIT, nurb_lb,
+		BKE_vfont_to_curve_ex(NULL, cu, FO_EDIT, nurb_lb,
 		                      NULL, NULL, NULL, NULL);
 		use_radius = false;
 	}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index f59691dd70e..dea1a3718dd 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1543,7 +1543,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
 		}
 
 		if (ob->type == OB_FONT) {
-			BKE_vfont_to_curve_nubase(G.main, ob, FO_EDIT, &nubase);
+			BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase);
 		}
 		else {
 			BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu));
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 39be0f67c93..73199cebe36 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -153,7 +153,7 @@ static PackedFile *get_builtin_packedfile(void)
 	}
 }
 
-static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
+static VFontData *vfont_get_data(VFont *vfont)
 {
 	if (vfont == NULL) {
 		return NULL;
@@ -188,10 +188,10 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
 				}
 			}
 			else {
-				pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
+				pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
 
 				if (vfont->temp_pf == NULL) {
-					vfont->temp_pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
+					vfont->temp_pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
 				}
 			}
 			if (!pf) {
@@ -349,13 +349,13 @@ VFont *BKE_vfont_builtin_get(void)
 {
 	VFont *vfont;
 	
-	for (vfont = G.main->vfont.first; vfont; vfont = vfont->id.next) {
+	for (vfont = G_MAIN->vfont.first; vfont; vfont = vfont->id.next) {
 		if (BKE_vfont_is_builtin(vfont)) {
 			return vfont;
 		}
 	}
 	
-	return BKE_vfont_load(G.main, FO_BUILTIN_NAME);
+	return BKE_vfont_load(G_MAIN, FO_BUILTIN_NAME);
 }
 
 static VChar *find_vfont_char(VFontData *vfd, unsigned int character)
@@ -423,7 +423,7 @@ static void build_underline(Curve *cu, ListBase *nubase, const rctf *rect,
 	mul_v2_fl(bp[3].vec, cu->fsize);
 }
 
-static void buildchar(Main *bmain, Curve *cu, ListBase *nubase, unsigned int character, CharInfo *info,
+static void buildchar(Curve *cu, ListBase *nubase, unsigned int character, CharInfo *info,
                       float ofsx, float ofsy, float rot, int charidx)
 {
 	BezTriple *bezt1, *bezt2;
@@ -433,7 +433,7 @@ static void buildchar(Main *bmain, Curve *cu, ListBase *nubase, unsigned int cha
 	VChar *che = NULL;
 	int i;
 
-	vfd = vfont_get_data(bmain, which_vfont(cu, info));
+	vfd = vfont_get_data(which_vfont(cu, info));
 	if (!vfd) return;
 
 #if 0
@@ -635,7 +635,7 @@ struct TempLineInfo {
 	int   wspace_nr;  /* number of whitespaces of line */
 };
 
-bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, Curve *cu, int mode, ListBase *r_nubase,
+bool BKE_vfont_to_curve_ex(Object *ob, Curve *cu, int mode, ListBase *r_nubase,
                            const wchar_t **r_text, int *r_text_len, bool *r_text_free,
                            struct CharTrans **r_chartransdata)
 {
@@ -677,7 +677,7 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, Curve *cu, int mode, ListBas
 	if (cu->str == NULL) return ok;
 	if (vfont == NULL) return ok;
 
-	vfd = vfont_get_data(bmain, vfont);
+	vfd = vfont_get_data(vfont);
 
 	/* The VFont Data can not be found */
 	if (!vfd) return ok;
@@ -770,7 +770,7 @@ makebreak:
 		if (vfont == NULL) break;
 
 		if (vfont != oldvfont) {
-			vfd = vfont_get_data(bmain, vfont);
+			vfd = vfont_get_data(vfont);
 			oldvfont = vfont;
 		}
 
@@ -1274,7 +1274,7 @@ makebreak:
 			}
 			/* We do not want to see any character for \n or \r */
 			if (cha != '\n')
-				buildchar(bmain, cu, r_nubase, cha, info, ct->xof, ct->yof, ct->rot, i);
+				buildchar(cu, r_nubase, cha, info, ct->xof, ct->yof, ct->rot, i);
 
 			if ((info->flag & CU_CHINFO_UNDERLINE) && (cha != '\n')) {
 				float ulwidth, uloverlap = 0.0f;
@@ -1340,19 +1340,19 @@ finally:
 }
 
 
-bool BKE_vfont_to_curve_nubase(Main *bmain, Object *ob, int mode, ListBase *r_nubase)
+bool BKE_vfont_to_curve_nubase(Object *ob, int mode, ListBase *r_nubase)
 {
 	BLI_assert(ob->type == OB_FONT);
 
-	return BKE_vfont_to_curve_ex(bmain, ob, ob->data, mode, r_nubase,
+	return BKE_vfont_to_curve_ex(ob, ob->data, mode, r_nubase,
 	                             NULL, NULL, NULL, NULL);
 }
 
-bool BKE_vfont_to_curve(Main *bmain, Object *ob, int mode)
+bool BKE_vfont_to_curve(Object *ob, int mode)
 {
 	Curve *cu = ob->data;
 
-	return BKE_vfont_to_curve_ex(bmain, ob, ob->data, mode, &cu->nurb, NULL, NULL, NULL, NULL);
+	return BKE_vfont_to_curve_ex(ob, ob->data, mode, &cu->nurb, NULL, NULL, NULL, NULL);
 }
 
 
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 19450b88947..97d2280c021 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -634,7 +634,7 @@ static void make_duplis_font(const DupliContext *ctx)
 
 	/* in par the family name is stored, use this to find the other objects */
 
-	BKE_vfont_to_curve_ex(G.main, par, par->data, FO_DUPLI, NULL,
+	BKE_vfont_to_curve_ex(par, par->data, FO_DUPLI, NULL,
 	                      &text, &text_len, &text_free, &chartransdata);
 
 	if (text == NULL || chartransdata == NULL) {
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index e4db0f1b3fc..bc4a4d0105d 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -245,7 +245,6 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
 
 static void text_update_edited(bContext *C, Object *obedit, int mode)
 {
-	struct Main *bmain = CTX_data_main(C);
 	Curve *cu = obedit->data;
 	EditFont *ef = cu->editfont;
 
@@ -258,7 +257,7 @@ static void text_update_edited(bContext *C, Object *obedit, int mode)
 	}
 	else {
 		/* depsgraph runs above, but since we're not tagging for update, call direct */
-		BKE_vfont_to_curve(bmain, obedit, mode);
+		BKE_vfont_to_curve(obedit, mode);
 	}
 
 	cu->curinfo = ef->textbufinfo[ef->pos ? ef->pos - 1 : 0];
@@ -977,16 +976,14 @@ static int move_cursor(bContext *C, int type, const bool select)
 	/* apply virtical cursor motion to position immediately
 	 * otherwise the selection will lag behind */
 	if (FO_CURS_IS_MOTION(cursmove)) {
-		struct Main *bmain = CTX_data_main(C);
-		BKE_vfont_to_curve(bmain, obedit, cursmove);
+		BKE_vfont_to_curve(obedit, cursmove);
 		cursmove = FO_CURS;
 	}
 
 	if (select == 0) {
 		if (ef->selstart) {
-			struct Main *bmain = CTX_data_main(C);
 			ef->selstart = ef->selend = 0;
-			BKE_vfont_to_curve(bmain, obedit, FO_SELCHANGE);
+			BKE_vfont_to_curve(obedit, FO_SELCHANGE);
 		}
 	}
 
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 039ea518b23..10121e8ae2f 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1785,7 +1785,7 @@ static int convert_exec(bContext *C, wmOperator *op)
 			 *               datablock, but for until we've got granular update
 			 *               lets take care by selves.
 			 */
-			BKE_vfont_to_curve(bmain, newob, FO_EDIT);
+			BKE_vfont_to_curve(newob, FO_EDIT);
 
 			newob->type = OB_CURVE;
 			cu->type = OB_CURVE;



More information about the Bf-blender-cvs mailing list