From ecabb2266ff3e0991dd674db83cc21da79acf339 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 18 Oct 2002 14:21:06 +0000 Subject: [PATCH] fix undo crash git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@5443 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 8 ++++++++ src/insets/ChangeLog | 5 +++++ src/insets/insettext.C | 16 +++++++++------- src/undo_funcs.C | 29 ++++++++++++++++++++--------- status.12x | 10 ++++++++++ 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e97bd25eeb..022b6fbeae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2002-10-14 Juergen Vigna + + * undo_funcs.C (textHandleUndo): alter the order in which the + new undopar is added to the LyXText, as we have to set first + the right prev/next and then add it as otherwise the rebuild of + LyXText is not correct. Also reset the cursor to the right paragraph, + with this IMO we could remove the hack in "redoParagraphs()". + 2002-10-14 Dekel Tsur * FontInfo.C (query): Ignore bogus matches of scalable fonts. diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index ad73dbb9de..f7e0a313f7 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2002-10-14 Juergen Vigna + + * insettext.C (localDispatch): remove double setUndo in Cut/Delete/ + Backspace functions which confused the Undo handling. + 2002-10-09 Angus Leeming * insetcite.[Ch] (setLoadingBuffer): new method, invoked by diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 6b626e1828..cbb3c96857 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1266,9 +1266,11 @@ InsetText::localDispatch(BufferView * bv, * typed in now. Depends on lyxrc settings * "auto_region_delete", which defaults to * true (on). */ - +#if 0 + // This should not be needed here and is also WRONG! setUndo(bv, Undo::INSERT, lt->cursor.par(), lt->cursor.par()->next()); +#endif bv->setState(); if (lyxrc.auto_region_delete) { if (lt->selection.set()) { @@ -1340,8 +1342,6 @@ InsetText::localDispatch(BufferView * bv, updwhat = CURSOR; break; case LFUN_BACKSPACE: { - setUndo(bv, Undo::DELETE, - lt->cursor.par(), lt->cursor.par()->next()); if (lt->selection.set()) lt->cutSelection(bv, true, false); else @@ -1352,8 +1352,6 @@ InsetText::localDispatch(BufferView * bv, break; case LFUN_DELETE: { - setUndo(bv, Undo::DELETE, - lt->cursor.par(), lt->cursor.par()->next()); if (lt->selection.set()) { lt->cutSelection(bv, true, false); } else { @@ -1365,8 +1363,6 @@ InsetText::localDispatch(BufferView * bv, break; case LFUN_CUT: { - setUndo(bv, Undo::DELETE, - lt->cursor.par(), lt->cursor.par()->next()); lt->cutSelection(bv); updwhat = CURSOR_PAR; updflag = true; @@ -1406,8 +1402,11 @@ InsetText::localDispatch(BufferView * bv, break; } } +#if 0 + // This should not be needed here and is also WRONG! setUndo(bv, Undo::INSERT, lt->cursor.par(), lt->cursor.par()->next()); +#endif lt->pasteSelection(bv); // bug 393 lt->clearSelection(); @@ -1440,8 +1439,11 @@ InsetText::localDispatch(BufferView * bv, result = DISPATCHED; break; } +#if 0 + // This should not be needed here and is also WRONG! setUndo(bv, Undo::INSERT, lt->cursor.par(), lt->cursor.par()->next()); +#endif lt->insertChar(bv, Paragraph::META_NEWLINE); updwhat = CURSOR | CURSOR_PAR; updflag = true; diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 8a9afeee35..c411fb8055 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -182,15 +182,25 @@ bool textHandleUndo(BufferView * bv, Undo * undo) } } + // The order here is VERY IMPORTANT. We have to set the right + // next/prev pointer in the paragraphs so that a rebuild of + // the LyXText works!!! + + // thread the end of the undo onto the par in front if any + if (tmppar4) { + tmppar4->next(behind); + if (behind) + behind->previous(tmppar4); + } + // put the new stuff in the list if there is one if (tmppar3) { + tmppar3->previous(before); if (before) before->next(tmppar3); else bv->text->ownerParagraph(firstUndoParagraph(bv, undo->number_of_inset_id)->id(), tmppar3); - - tmppar3->previous(before); } else { // We enter here on DELETE undo operations where we have to // substitue the second paragraph with the first if the removed @@ -201,20 +211,21 @@ bool textHandleUndo(BufferView * bv, Undo * undo) tmppar3 = behind; } } - if (tmppar4) { - tmppar4->next(behind); - if (behind) - behind->previous(tmppar4); - } - // Set the cursor for redoing - if (before) { + if (before) { // if we have a par before the undopar Inset * it = before->inInset(); if (it) it->getLyXText(bv)->setCursorIntern(bv, before, 0); else bv->text->setCursorIntern(bv, before, 0); + } else { // otherwise this is the first one and we start here + Inset * it = tmppar3->inInset(); + if (it) + it->getLyXText(bv)->setCursorIntern(bv, tmppar3, 0); + else + bv->text->setCursorIntern(bv, tmppar3, 0); + } Paragraph * endpar = 0; diff --git a/status.12x b/status.12x index 3fc5373668..41f9fb9e60 100644 --- a/status.12x +++ b/status.12x @@ -46,11 +46,16 @@ What's new - fix bug with handling of EPSI files (this was a new bug in 1.2.1) +- fix crash with undo + - fix lockup when changing the layout of several paragraphs at the same time (and the layout of the first paragraph is already correct) - fix bug with graphics files which name contain a '.' +- fix bug in the xforms image loader, where images would be cropped by + a couple pixels + - when a viewer has not been found (set to "none"), remove the corresponding View menu entry @@ -72,9 +77,14 @@ What's new - fix drawing problem when a line of text contains both left-to-right and right-to-left text +- ignore bugs matches of scalable fonts + - when loading a font fails, show the name of the said font - harmonize the behavior of delete and backspace in main text, insettext, and tabulars, i.e. don't put stuff into the clipboard - add missing autoconf file xforms.m4 + +- fix compilation problem (missing ) on some BSD systems + (including Mac OS X)