From b007ad818bffe044223e04ea004669d4fd6be023 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 16 Feb 2008 13:35:42 +0000 Subject: [PATCH] Avoid paragraphs with no children git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@51839 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextbuffer.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 34aec251a3..286d403ce1 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -1466,15 +1466,7 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range) { wxRichTextObject* obj1 = node1->GetData(); - // If the object is empty, optimise it out - if (obj1->IsEmpty()) - { - delete obj1; - } - else - { - firstPara->AppendChild(obj1); - } + firstPara->AppendChild(obj1); wxRichTextObjectList::compatibility_iterator next1 = node1->GetNext(); nextParagraph->GetChildren().Erase(node1); @@ -1486,6 +1478,13 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range) RemoveChild(nextParagraph, true); } + // Avoid empty paragraphs + if (firstPara && firstPara->GetChildren().GetCount() == 0) + { + wxRichTextPlainText* text = new wxRichTextPlainText(wxEmptyString); + firstPara->AppendChild(text); + } + if (applyFinalParagraphStyle) firstPara->SetAttributes(nextParaAttr);