fix undo crash

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@5443 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-10-18 14:21:06 +00:00
parent 99b0a3d98a
commit ecabb2266f
5 changed files with 52 additions and 16 deletions

View File

@ -1,3 +1,11 @@
2002-10-14 Juergen Vigna <jug@sad.it>
* 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 <dekelts@tau.ac.il> 2002-10-14 Dekel Tsur <dekelts@tau.ac.il>
* FontInfo.C (query): Ignore bogus matches of scalable fonts. * FontInfo.C (query): Ignore bogus matches of scalable fonts.

View File

@ -1,3 +1,8 @@
2002-10-14 Juergen Vigna <jug@sad.it>
* insettext.C (localDispatch): remove double setUndo in Cut/Delete/
Backspace functions which confused the Undo handling.
2002-10-09 Angus Leeming <leeming@lyx.org> 2002-10-09 Angus Leeming <leeming@lyx.org>
* insetcite.[Ch] (setLoadingBuffer): new method, invoked by * insetcite.[Ch] (setLoadingBuffer): new method, invoked by

View File

@ -1266,9 +1266,11 @@ InsetText::localDispatch(BufferView * bv,
* typed in now. Depends on lyxrc settings * typed in now. Depends on lyxrc settings
* "auto_region_delete", which defaults to * "auto_region_delete", which defaults to
* true (on). */ * true (on). */
#if 0
// This should not be needed here and is also WRONG!
setUndo(bv, Undo::INSERT, setUndo(bv, Undo::INSERT,
lt->cursor.par(), lt->cursor.par()->next()); lt->cursor.par(), lt->cursor.par()->next());
#endif
bv->setState(); bv->setState();
if (lyxrc.auto_region_delete) { if (lyxrc.auto_region_delete) {
if (lt->selection.set()) { if (lt->selection.set()) {
@ -1340,8 +1342,6 @@ InsetText::localDispatch(BufferView * bv,
updwhat = CURSOR; updwhat = CURSOR;
break; break;
case LFUN_BACKSPACE: { case LFUN_BACKSPACE: {
setUndo(bv, Undo::DELETE,
lt->cursor.par(), lt->cursor.par()->next());
if (lt->selection.set()) if (lt->selection.set())
lt->cutSelection(bv, true, false); lt->cutSelection(bv, true, false);
else else
@ -1352,8 +1352,6 @@ InsetText::localDispatch(BufferView * bv,
break; break;
case LFUN_DELETE: { case LFUN_DELETE: {
setUndo(bv, Undo::DELETE,
lt->cursor.par(), lt->cursor.par()->next());
if (lt->selection.set()) { if (lt->selection.set()) {
lt->cutSelection(bv, true, false); lt->cutSelection(bv, true, false);
} else { } else {
@ -1365,8 +1363,6 @@ InsetText::localDispatch(BufferView * bv,
break; break;
case LFUN_CUT: { case LFUN_CUT: {
setUndo(bv, Undo::DELETE,
lt->cursor.par(), lt->cursor.par()->next());
lt->cutSelection(bv); lt->cutSelection(bv);
updwhat = CURSOR_PAR; updwhat = CURSOR_PAR;
updflag = true; updflag = true;
@ -1406,8 +1402,11 @@ InsetText::localDispatch(BufferView * bv,
break; break;
} }
} }
#if 0
// This should not be needed here and is also WRONG!
setUndo(bv, Undo::INSERT, setUndo(bv, Undo::INSERT,
lt->cursor.par(), lt->cursor.par()->next()); lt->cursor.par(), lt->cursor.par()->next());
#endif
lt->pasteSelection(bv); lt->pasteSelection(bv);
// bug 393 // bug 393
lt->clearSelection(); lt->clearSelection();
@ -1440,8 +1439,11 @@ InsetText::localDispatch(BufferView * bv,
result = DISPATCHED; result = DISPATCHED;
break; break;
} }
#if 0
// This should not be needed here and is also WRONG!
setUndo(bv, Undo::INSERT, setUndo(bv, Undo::INSERT,
lt->cursor.par(), lt->cursor.par()->next()); lt->cursor.par(), lt->cursor.par()->next());
#endif
lt->insertChar(bv, Paragraph::META_NEWLINE); lt->insertChar(bv, Paragraph::META_NEWLINE);
updwhat = CURSOR | CURSOR_PAR; updwhat = CURSOR | CURSOR_PAR;
updflag = true; updflag = true;

View File

@ -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 // put the new stuff in the list if there is one
if (tmppar3) { if (tmppar3) {
tmppar3->previous(before);
if (before) if (before)
before->next(tmppar3); before->next(tmppar3);
else else
bv->text->ownerParagraph(firstUndoParagraph(bv, undo->number_of_inset_id)->id(), bv->text->ownerParagraph(firstUndoParagraph(bv, undo->number_of_inset_id)->id(),
tmppar3); tmppar3);
tmppar3->previous(before);
} else { } else {
// We enter here on DELETE undo operations where we have to // We enter here on DELETE undo operations where we have to
// substitue the second paragraph with the first if the removed // substitue the second paragraph with the first if the removed
@ -201,20 +211,21 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
tmppar3 = behind; tmppar3 = behind;
} }
} }
if (tmppar4) {
tmppar4->next(behind);
if (behind)
behind->previous(tmppar4);
}
// Set the cursor for redoing // Set the cursor for redoing
if (before) { if (before) { // if we have a par before the undopar
Inset * it = before->inInset(); Inset * it = before->inInset();
if (it) if (it)
it->getLyXText(bv)->setCursorIntern(bv, before, 0); it->getLyXText(bv)->setCursorIntern(bv, before, 0);
else else
bv->text->setCursorIntern(bv, before, 0); 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; Paragraph * endpar = 0;

View File

@ -46,11 +46,16 @@ What's new
- fix bug with handling of EPSI files (this was a new bug in 1.2.1) - 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 - fix lockup when changing the layout of several paragraphs at the
same time (and the layout of the first paragraph is already correct) same time (and the layout of the first paragraph is already correct)
- fix bug with graphics files which name contain a '.' - 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 - when a viewer has not been found (set to "none"), remove the
corresponding View menu entry corresponding View menu entry
@ -72,9 +77,14 @@ What's new
- fix drawing problem when a line of text contains both left-to-right - fix drawing problem when a line of text contains both left-to-right
and right-to-left text and right-to-left text
- ignore bugs matches of scalable fonts
- when loading a font fails, show the name of the said font - when loading a font fails, show the name of the said font
- harmonize the behavior of delete and backspace in main text, - harmonize the behavior of delete and backspace in main text,
insettext, and tabulars, i.e. don't put stuff into the clipboard insettext, and tabulars, i.e. don't put stuff into the clipboard
- add missing autoconf file xforms.m4 - add missing autoconf file xforms.m4
- fix compilation problem (missing <wchar.h>) on some BSD systems
(including Mac OS X)