From 875cec0af0daec117f6c7bd8d61e7d585bd7b4b0 Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Mon, 27 Oct 2003 10:03:04 +0000 Subject: [PATCH] undo fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7982 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/undo.C | 18 +++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ea694eff78..474449bb92 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-10-27 Alfredo Braunstein + + * undo.C (performUndoOrRedo): fix two crashes by setting a + cursor by hand and reordering some calls. Use bv->lockInset instead + of inset->edit because the latter loses cursor information + 2003-10-25 Martin Vermeer * MenuBackend.C: diff --git a/src/undo.C b/src/undo.C index bd2d6d0181..7f38077479 100644 --- a/src/undo.C +++ b/src/undo.C @@ -23,6 +23,8 @@ #include "lyxtext.h" #include "paragraph.h" +#include "insets/updatableinset.h" // for dynamic_cast + using lyx::paroffset_type; @@ -188,23 +190,25 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo) << " inset: " << pit.inset() << " index: " << undo.index << std::endl; - InsetOld * inset = pit.inset(); - if (inset) { - // magic needed to cope with inset locking - inset->edit(bv, undo.index); - } // set cursor again to force the position to be the right one - text->setCursorIntern(undo.cursor_par, undo.cursor_pos); + text->cursor.par(undo.cursor_par); + text->cursor.pos(undo.cursor_pos); // clear any selection text->clearSelection(); text->selection.cursor = text->cursor; text->updateCounters(); - // rebreak the entire document + // rebreak the entire lyxtext bv->text->fullRebreak(); + InsetOld * inset = pit.inset(); + if (inset) { + // magic needed to cope with inset locking + bv->lockInset(dynamic_cast(inset)); + } + finishUndo(); return true; }