[Bf-blender-cvs] [a2bf25e] master: Fix crash when having multiple text objects sharing the same curve datablock

Sergey Sharybin noreply at git.blender.org
Sun Jan 5 12:38:54 CET 2014


Commit: a2bf25e8ff7172643fa156cb12d42582595ecd7d
Author: Sergey Sharybin
Date:   Sun Jan 5 17:04:52 2014 +0600
https://developer.blender.org/rBa2bf25e8ff7172643fa156cb12d42582595ecd7d

Fix crash when having multiple text objects sharing the same curve datablock

Issue was caused by BKE_vfont_to_curve() modifying curve->nurbs list which
gave threading issues.

Now added BKE_vfont_to_curve_nubase() which operates on a given nurbs list
base which is local in do_makeDispListCurveTypes().

By the looks of it it wouldn't give speed regression because previously it
also was creating nurbs for every font object sharing the same curve data.

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

M	source/blender/blenkernel/BKE_font.h
M	source/blender/blenkernel/intern/displist.c
M	source/blender/blenkernel/intern/font.c

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

diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index 85aaafd..199b194 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -83,6 +83,9 @@ void BKE_vfont_free(struct VFont *sc);
 struct VFont *BKE_vfont_builtin_get(void);
 struct VFont *BKE_vfont_load(struct Main *bmain, const char *name);
 
+bool BKE_vfont_to_curve_nubase(struct Main *bmain, struct Scene *scene, struct Object *ob,
+                               struct ListBase *nubase, int mode, struct CharTrans **r_chartransdata);
+
 bool BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode,
                         struct CharTrans **r_chartransdata);
 
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index b9d89be..4282e86 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1374,10 +1374,12 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
 		if (ob->curve_cache->path) free_path(ob->curve_cache->path);
 		ob->curve_cache->path = NULL;
 
-		if (ob->type == OB_FONT)
-			BKE_vfont_to_curve(G.main, scene, ob, FO_EDIT, NULL);
-
-		BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu));
+		if (ob->type == OB_FONT) {
+			BKE_vfont_to_curve_nubase(G.main, scene, ob, &nubase, FO_EDIT, NULL);
+		}
+		else {
+			BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu));
+		}
 
 		if (!forOrco)
 			curve_calc_modifiers_pre(scene, ob, &nubase, forRender, renderResolution);
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 556e9dc..2a5f8cb 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -293,7 +293,7 @@ static VChar *find_vfont_char(VFontData *vfd, unsigned int character)
 	return BLI_ghash_lookup(vfd->characters, SET_UINT_IN_POINTER(character));
 }
 		
-static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, int charidx, short mat_nr)
+static void build_underline(Curve *cu, ListBase *nubase, float x1, float y1, float x2, float y2, int charidx, short mat_nr)
 {
 	Nurb *nu2;
 	BPoint *bp;
@@ -324,11 +324,11 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
 	copy_v4_fl4(bp[3].vec, x1, y2, 0.0f, 1.0f);
 
 	nu2->bp = bp;
-	BLI_addtail(&(cu->nurb), nu2);
+	BLI_addtail(nubase, nu2);
 
 }
 
-static void buildchar(Main *bmain, Curve *cu, unsigned int character, CharInfo *info,
+static void buildchar(Main *bmain, Curve *cu, ListBase *nubase, unsigned int character, CharInfo *info,
                       float ofsx, float ofsy, float rot, int charidx)
 {
 	BezTriple *bezt1, *bezt2;
@@ -450,7 +450,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned int character, CharInfo *
 				bezt2++;
 			}
 			
-			BLI_addtail(&(cu->nurb), nu2);
+			BLI_addtail(nubase, nu2);
 		}
 		
 		nu1 = nu1->next;
@@ -495,8 +495,8 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info)
 	}
 }
 
-bool BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode,
-                        struct CharTrans **r_chartransdata)
+bool BKE_vfont_to_curve_nubase(Main *bmain, Scene *scene, Object *ob, ListBase *nubase,
+                               int mode, struct CharTrans **r_chartransdata)
 {
 	Curve *cu = ob->data;
 	EditFont *ef = cu->editfont;
@@ -1020,7 +1020,7 @@ makebreak:
 
 	if (mode == FO_EDIT) {
 		/* make nurbdata */
-		BKE_nurbList_free(&cu->nurb);
+		BKE_nurbList_free(nubase);
 		
 		ct = chartransdata;
 		for (i = 0; i < slen; i++) {
@@ -1037,7 +1037,7 @@ makebreak:
 			}
 			/* We do not want to see any character for \n or \r */
 			if (cha != '\n' && cha != '\r')
-				buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i);
+				buildchar(bmain, cu, nubase, cha, info, ct->xof, ct->yof, ct->rot, i);
 
 			if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) {
 				float ulwidth, uloverlap = 0.0f;
@@ -1054,7 +1054,8 @@ makebreak:
 
 				twidth = char_width(cu, che, info);
 				ulwidth = cu->fsize * ((twidth * (1.0f + (info->kern / 40.0f))) + uloverlap);
-				build_underline(cu, ct->xof * cu->fsize, ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize,
+				build_underline(cu, nubase,
+				                ct->xof * cu->fsize, ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize,
 				                ct->xof * cu->fsize + ulwidth,
 				                ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize - cu->ulheight * cu->fsize,
 				                i, info->mat_nr);
@@ -1081,3 +1082,13 @@ finally:
 
 	return ok;
 }
+
+bool BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode,
+                        struct CharTrans **r_chartransdata)
+{
+	Curve *cu = (Curve *) ob->data;
+
+	BLI_assert(ob->type == OB_FONT);
+
+	return BKE_vfont_to_curve_nubase(bmain, scene, ob, &cu->nurb, mode, r_chartransdata);
+}




More information about the Bf-blender-cvs mailing list