From 6f5f012d3d396b332ce3922b56405a39b89d352d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Wed, 5 Dec 2001 16:11:47 +0000 Subject: [PATCH] Fixed faulte delete of paragraphs in a special case. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3152 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 2 ++ src/insets/insettext.C | 17 +++++++++++------ src/text2.C | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index df0cad75bf..03761e345c 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -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 diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 5775594a9b..1e6ae4a8f2 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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! diff --git a/src/text2.C b/src/text2.C index 3b2df2e203..019f7b891c 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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()); -- 2.39.2