From: Julian Smart Date: Sun, 27 Apr 2008 17:17:18 +0000 (+0000) Subject: Bug fix for empty objects X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/affbfa1f2992c3f9778547f1d73743aefcc270d4 Bug fix for empty objects git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53384 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 0c2e22642a..b6b9fcf674 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -3206,7 +3206,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR { wxRichTextObject* child = node2->GetData(); - if (!child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range)) + if (child->GetRange().GetLength() > 0 && !child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range)) { // Draw this part of the line at the correct position wxRichTextRange objectRange(child->GetRange()); @@ -3251,6 +3251,9 @@ static int wxRichTextGetRangeWidth(const wxRichTextParagraph& para, const wxRich { wxASSERT(partialExtents.GetCount() >= (size_t) range.GetLength()); + if (partialExtents.GetCount() < (size_t) range.GetLength()) + return 0; + int leftMostPos = 0; if (range.GetStart() - para.GetRange().GetStart() > 0) leftMostPos = partialExtents[range.GetStart() - para.GetRange().GetStart() - 1]; @@ -3353,6 +3356,12 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) { wxRichTextObject* child = node->GetData(); + if (child->GetRange().GetLength() == 0) + { + node = node->GetNext(); + continue; + } + // If this is e.g. a composite text box, it will need to be laid out itself. // But if just a text fragment or image, for example, this will // do nothing. NB: won't we need to set the position after layout? @@ -3542,7 +3551,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) { wxRichTextObject* child = node2->GetData(); - if (!child->GetRange().IsOutside(lineRange)) + if (child->GetRange().GetLength() > 0 && !child->GetRange().IsOutside(lineRange)) { wxRichTextRange rangeToUse = lineRange; rangeToUse.LimitTo(child->GetRange());