From 00217f95a4d94fe9ff67fc3966734fd61de5456d Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 27 Apr 2008 17:17:08 +0000 Subject: [PATCH] Bug fix for empty objects git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53383 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextbuffer.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 3c2bc94422..12f91d4133 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -3326,7 +3326,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()); @@ -3372,6 +3372,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]; @@ -3475,6 +3478,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? @@ -3664,7 +3673,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());