]> git.saurik.com Git - wxWidgets.git/commitdiff
Avoid paragraphs with no children
authorJulian Smart <julian@anthemion.co.uk>
Sat, 16 Feb 2008 13:36:03 +0000 (13:36 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sat, 16 Feb 2008 13:36:03 +0000 (13:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextbuffer.cpp

index ae5b2c223b425b069b27bf0b619fba77144fbcac..182f791719acfda7824203bf9e5589142090b918 100644 (file)
@@ -1468,15 +1468,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);
@@ -1488,6 +1480,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);