Hi Juergen,
I thought I might assist you in transforming the undo patch for LyX
1.2.2. Attached please find a modified patch.
Please note that this was just mechanical work. I DIDN'T REALLY
UNDERSTAND WHAT I WAS DOING :-) However, it might be a good starting
point for you.
The patch seems to fix at least one of my former problems and there are
no valgrind reports anymore. But I didn't have the time for thourough
testing. I will do so within the next couple of days. If you believe the
patch is OK don't wait for my comments and apply it to 1.2.2cvs. I
always work with the latest cvs version of the 1.2.X branch.
Michael
Index: lyx-devel/src/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.713.2.43
diff -u -p -r1.713.2.43 ChangeLog
--- lyx-devel/src/ChangeLog 2002/10/15 14:48:29 1.713.2.43
+++ lyx-devel/src/ChangeLog 2002/10/16 21:53:56
@@ -1,3 +1,11 @@
+2002-10-14 Juergen Vigna <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
* FontInfo.C (query): Ignore bogus matches of scalable fonts.
Index: lyx-devel/src/undo_funcs.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/undo_funcs.C,v
retrieving revision 1.22.2.1
diff -u -p -r1.22.2.1 undo_funcs.C
--- lyx-devel/src/undo_funcs.C 2002/05/24 12:03:38 1.22.2.1
+++ lyx-devel/src/undo_funcs.C 2002/10/16 21:54:06
@@ -182,15 +182,25 @@ bool textHandleUndo(BufferView * bv, Und
}
}
+ // 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, Und
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;
Index: lyx-devel/src/insets/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.421.2.24
diff -u -p -r1.421.2.24 ChangeLog
--- lyx-devel/src/insets/ChangeLog 2002/10/15 10:43:31 1.421.2.24
+++ lyx-devel/src/insets/ChangeLog 2002/10/16 21:54:16
@@ -1,3 +1,8 @@
+2002-10-14 Juergen Vigna <[EMAIL PROTECTED]>
+
+ * insettext.C (localDispatch): remove double setUndo in Cut/Delete/
+ Backspace functions which confused the Undo handling.
+
2002-10-09 Angus Leeming <[EMAIL PROTECTED]>
* insetcite.[Ch] (setLoadingBuffer): new method, invoked by
Index: lyx-devel/src/insets/insettext.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.293.2.4
diff -u -p -r1.293.2.4 insettext.C
--- lyx-devel/src/insets/insettext.C 2002/08/27 11:27:47 1.293.2.4
+++ lyx-devel/src/insets/insettext.C 2002/10/16 21:54:21
@@ -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;