[Bf-blender-cvs] [f22ef1706d4] master: Fix T55662: Crash on text autocomplete

Campbell Barton noreply at git.blender.org
Thu Jun 28 11:09:48 CEST 2018


Commit: f22ef1706d440cfdc91af99a8d4ab9952fad882b
Author: Campbell Barton
Date:   Thu Jun 28 11:09:09 2018 +0200
Branches: master
https://developer.blender.org/rBf22ef1706d440cfdc91af99a8d4ab9952fad882b

Fix T55662: Crash on text autocomplete

Regression from undo system upgrade.

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

M	source/blender/editors/space_text/text_autocomplete.c

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

diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index 9163831c333..4f6a3bc82ba 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -40,7 +40,10 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "ED_text.h"
+#include "ED_undo.h"
 #include "ED_screen.h"
+
 #include "UI_interface.h"
 
 #include "text_format.h"
@@ -284,10 +287,11 @@ static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *
 		ED_area_tag_redraw(CTX_wm_area(C));
 
 		if (texttool_suggest_first() == texttool_suggest_last()) {
-			TextUndoBuf *utxt = NULL; // FIXME
+			TextUndoBuf *utxt = ED_text_undo_push_init(C);
 			confirm_suggestion(st->text, utxt);
 			text_update_line_edited(st->text->curl);
 			text_autocomplete_free(C, op);
+			ED_undo_push(C, op->type->name);
 			return OPERATOR_FINISHED;
 		}
 		else {
@@ -315,8 +319,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
 
 	(void)text;
 
-	TextUndoBuf *utxt = NULL; // FIXME
-
 	if (st->doplugins && texttool_text_is_active(st->text)) {
 		if (texttool_suggest_first()) tools |= TOOL_SUGG_LIST;
 		if (texttool_docs_get()) tools |= TOOL_DOCUMENT;
@@ -343,8 +345,10 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
 		case MIDDLEMOUSE:
 			if (event->val == KM_PRESS) {
 				if (text_do_suggest_select(st, ar)) {
+					TextUndoBuf *utxt = ED_text_undo_push_init(C);
 					confirm_suggestion(st->text, utxt);
 					text_update_line_edited(st->text->curl);
+					ED_undo_push(C, op->type->name);
 					swallow = 1;
 				}
 				else {
@@ -378,8 +382,10 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
 		case PADENTER:
 			if (event->val == KM_PRESS) {
 				if (tools & TOOL_SUGG_LIST) {
+					TextUndoBuf *utxt = ED_text_undo_push_init(C);
 					confirm_suggestion(st->text, utxt);
 					text_update_line_edited(st->text->curl);
+					ED_undo_push(C, op->type->name);
 					swallow = 1;
 					draw = 1;
 				}
@@ -591,5 +597,6 @@ void TEXT_OT_autocomplete(wmOperatorType *ot)
 	ot->poll = text_space_edit_poll;
 
 	/* flags */
+	/* Undo is handled conditionally by this operator. */
 	ot->flag = OPTYPE_BLOCKING;
 }



More information about the Bf-blender-cvs mailing list