]> git.lyx.org Git - features.git/commitdiff
Fixed faulte delete of paragraphs in a special case.
authorJürgen Vigna <jug@sad.it>
Wed, 5 Dec 2001 16:11:47 +0000 (16:11 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 5 Dec 2001 16:11:47 +0000 (16:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3152 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insettext.C
src/text2.C

index df0cad75bf4ea629057b8d3ba01df1c984551da5..03761e345c593deddb29a58a541e78f7c622b383 100644 (file)
@@ -2,6 +2,8 @@
 
        * insettext.C (insetAllowed): fixed for the case that we directly
        ask the insettext from it's LyXText.
+       (paragraph): fixed the crash when assigning the par->next() from
+       the EmptyParagraphMechanism!
 
 2001-12-05  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
index 5775594a9b39463cbcba23acc59d7d70ae1188b2..1e6ae4a8f2c385ab2747f5ec24b96f626c83d1e9 100644 (file)
@@ -2383,12 +2383,17 @@ Paragraph * InsetText::paragraph() const
 void InsetText::paragraph(Paragraph * p)
 {
        // first we have to delete the old contents otherwise we'll have a
-       // memory leak!
-       the_locking_inset = 0;
-       while (par) {
-               Paragraph * tmp = par->next();
-               delete par;
-               par = tmp;
+       // memory leak! But there check that we don't delete the paragraphs
+       // the new par is refering to (could happen in LyXText::EmptyParagrapM...)
+       // well don't do deletes at all if we come from there. Really stupid
+       // thing! (Jug 20011205)
+       if (par->next() != p) {
+               the_locking_inset = 0;
+               while (par && par != p) {
+                       Paragraph * tmp = par->next();
+                       delete par;
+                       par = tmp;
+               }
        }
        par = p;
        // set ourself as owner for all the paragraphs inserted!
index 3b2df2e203291cad37a9ebf50b96e8750a8fd27c..019f7b891cfdb18d73a8994bbbdac5df0b83ded2 100644 (file)
@@ -2473,7 +2473,7 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
                        setUndo(bview, Undo::DELETE, old_cursor.par(), endpar);
                        cursor = tmpcursor;
 
-                               // delete old row
+                       // delete old row
                        removeRow(old_cursor.row());
                        if (ownerParagraph() == old_cursor.par()) {
                                ownerParagraph(ownerParagraph()->next());