diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-07-10 14:29:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-07-10 14:42:17 +0300 |
commit | 956d38488a2a996d2a28c957f4f6ed9fc587983a (patch) | |
tree | d15bf8d229f62deecffc092a1a085d91f3c8e800 /source/blender/editors/space_text | |
parent | 56ec8108e27c13fa36f8f47780d812e9207e2ec2 (diff) |
Undo System: ensure the text ID for each undo step is used
In practice this wasn't causing errors,
however it could be an issue in the future.
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r-- | source/blender/editors/space_text/text_undo.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/source/blender/editors/space_text/text_undo.c b/source/blender/editors/space_text/text_undo.c index 7db97f15a68..7710c5637a2 100644 --- a/source/blender/editors/space_text/text_undo.c +++ b/source/blender/editors/space_text/text_undo.c @@ -130,7 +130,7 @@ static void text_undosys_step_decode_redo_impl(Text *text, TextUndoStep *us) us->step.is_applied = true; } -static void text_undosys_step_decode_undo(Text *text, TextUndoStep *us) +static void text_undosys_step_decode_undo(TextUndoStep *us) { TextUndoStep *us_iter = us; while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) { @@ -139,13 +139,19 @@ static void text_undosys_step_decode_undo(Text *text, TextUndoStep *us) } us_iter = (TextUndoStep *)us_iter->step.next; } + Text *text_prev = NULL; while (us_iter != us) { + Text *text = us_iter->text_ref.ptr; text_undosys_step_decode_undo_impl(text, us_iter); + if (text_prev != text) { + text_update_edited(text); + text_prev = text; + } us_iter = (TextUndoStep *)us_iter->step.prev; } } -static void text_undosys_step_decode_redo(Text *text, TextUndoStep *us) +static void text_undosys_step_decode_redo(TextUndoStep *us) { TextUndoStep *us_iter = us; while (us_iter->step.prev && (us_iter->step.prev->type == us_iter->step.type)) { @@ -154,8 +160,14 @@ static void text_undosys_step_decode_redo(Text *text, TextUndoStep *us) } us_iter = (TextUndoStep *)us_iter->step.prev; } + Text *text_prev = NULL; while (us_iter && (us_iter->step.is_applied == false)) { + Text *text = us_iter->text_ref.ptr; text_undosys_step_decode_redo_impl(text, us_iter); + if (text_prev != text) { + text_update_edited(text); + text_prev = text; + } if (us_iter == us) { break; } @@ -169,21 +181,20 @@ static void text_undosys_step_decode(struct bContext *C, int dir) { TextUndoStep *us = (TextUndoStep *)us_p; - Text *text = us->text_ref.ptr; if (dir < 0) { - text_undosys_step_decode_undo(text, us); + text_undosys_step_decode_undo(us); } else { - text_undosys_step_decode_redo(text, us); + text_undosys_step_decode_redo(us); } + Text *text = us->text_ref.ptr; SpaceText *st = CTX_wm_space_text(C); if (st) { /* Not essential, always show text being undo where possible. */ st->text = text; } - text_update_edited(text); text_update_cursor_moved(C); text_drawcache_tag_update(st, 1); WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); |