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.
This commit is contained in:
parent
be57cf9b2a
commit
d617a6c85b
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue