[Bf-blender-cvs] [3a09ff77a1d] blender2.8: Fix T56879: Blender2.8 Crash when Editing Text on Curve.

Bastien Montagne noreply at git.blender.org
Sun Sep 30 21:37:45 CEST 2018


Commit: 3a09ff77a1d74af2df7da5225c8292d3cf1243a6
Author: Bastien Montagne
Date:   Sun Sep 30 21:36:02 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB3a09ff77a1d74af2df7da5225c8292d3cf1243a6

Fix T56879: Blender2.8 Crash when Editing Text on Curve.

Moving cursor in 3D text edit mode calls `BKE_vfont_to_curve_ex()`,
which expects to work with evaluated data (curve cache runtime etc.).

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

M	source/blender/blenkernel/intern/font.c
M	source/blender/editors/curve/editfont.c
M	source/blender/editors/object/object_add.c

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

diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 587a2612997..b81d633f156 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -1392,6 +1392,7 @@ bool BKE_vfont_to_curve_nubase(Object *ob, int mode, ListBase *r_nubase)
 	                             NULL, NULL, NULL, NULL);
 }
 
+/** Warning: expects to have access to evaluated data (i.e. passed object should be evaluated one...). */
 bool BKE_vfont_to_curve(Object *ob, int mode)
 {
 	Curve *cu = ob->data;
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 0275cb68550..b87584dc8b7 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -56,6 +56,7 @@
 #include "BKE_report.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -246,6 +247,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
 
 static void text_update_edited(bContext *C, Object *obedit, int mode)
 {
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);
 	Curve *cu = obedit->data;
 	EditFont *ef = cu->editfont;
 
@@ -258,7 +260,8 @@ 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(obedit, mode);
+		/* We need evaluated data here. */
+		BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), mode);
 	}
 
 	cu->curinfo = ef->textbufinfo[ef->pos ? ef->pos - 1 : 0];
@@ -895,6 +898,7 @@ static const EnumPropertyItem move_type_items[] = {
 
 static int move_cursor(bContext *C, int type, const bool select)
 {
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);
 	Object *obedit = CTX_data_edit_object(C);
 	Curve *cu = obedit->data;
 	EditFont *ef = cu->editfont;
@@ -977,17 +981,17 @@ static int move_cursor(bContext *C, int type, const bool select)
 	else if (ef->pos >= MAXTEXT) ef->pos = MAXTEXT;
 	else if (ef->pos < 0)        ef->pos = 0;
 
-	/* apply virtical cursor motion to position immediately
+	/* apply vertical cursor motion to position immediately
 	 * otherwise the selection will lag behind */
 	if (FO_CURS_IS_MOTION(cursmove)) {
-		BKE_vfont_to_curve(obedit, cursmove);
+		BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), cursmove);
 		cursmove = FO_CURS;
 	}
 
 	if (select == 0) {
 		if (ef->selstart) {
 			ef->selstart = ef->selend = 0;
-			BKE_vfont_to_curve(obedit, FO_SELCHANGE);
+			BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), FO_SELCHANGE);
 		}
 	}
 
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index c6f9c1230a6..3fccb5f6943 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1942,6 +1942,7 @@ static int convert_exec(bContext *C, wmOperator *op)
 			 *               datablock, but for until we've got granular update
 			 *               lets take care by selves.
 			 */
+			/* XXX This may fail/crash, since BKE_vfont_to_curve() accesses evaluated data in some cases (bastien). */
 			BKE_vfont_to_curve(newob, FO_EDIT);
 
 			newob->type = OB_CURVE;



More information about the Bf-blender-cvs mailing list