From f22ef1706d440cfdc91af99a8d4ab9952fad882b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 28 Jun 2018 11:09:09 +0200 Subject: Fix T55662: Crash on text autocomplete Regression from undo system upgrade. --- source/blender/editors/space_text/text_autocomplete.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/blender') 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; } -- cgit v1.2.3