X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/476a319a8f9c56f31e7501aa56e035be094a9c30..69e087c14439f0e92d3c8cc5e97d66b7e6e7ffea:/src/richtext/richtextbuffer.cpp diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index fc722e8b62..c4b472a491 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -2469,7 +2469,7 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& { // Stop searching if we're beyond the range of interest if (para->GetRange().GetStart() > range.GetEnd()) - return foundCount == matchingCount; + return foundCount == matchingCount && foundCount != 0; if (!para->GetRange().IsOutside(range)) { @@ -2478,7 +2478,12 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& while (node2) { wxRichTextObject* child = node2->GetData(); - if (!child->GetRange().IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText))) + // Allow for empty string if no buffer + wxRichTextRange childRange = child->GetRange(); + if (childRange.GetLength() == 0 && GetRange().GetLength() == 1) + childRange.SetEnd(childRange.GetEnd()+1); + + if (!childRange.IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText))) { foundCount ++; wxTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes()); @@ -2495,7 +2500,7 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& node = node->GetNext(); } - return foundCount == matchingCount; + return foundCount == matchingCount && foundCount != 0; } /// Test if this whole range has paragraph attributes of the specified kind. If any @@ -2517,7 +2522,7 @@ bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& { // Stop searching if we're beyond the range of interest if (para->GetRange().GetStart() > range.GetEnd()) - return foundCount == matchingCount; + return foundCount == matchingCount && foundCount != 0; if (!para->GetRange().IsOutside(range)) { @@ -2533,7 +2538,7 @@ bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& node = node->GetNext(); } - return foundCount == matchingCount; + return foundCount == matchingCount && foundCount != 0; } void wxRichTextParagraphLayoutBox::Clear() @@ -6959,8 +6964,12 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent // Detect last line in the buffer else if (!node2->GetNext() && para->GetRange().Contains(m_buffer->GetRange().GetEnd())) { - foundEnd = true; - lastY = pt.y + line->GetSize().y; + // If deleting text, make sure we refresh below as well as above + if (positionOffset >= 0) + { + foundEnd = true; + lastY = pt.y + line->GetSize().y; + } node2 = wxRichTextLineList::compatibility_iterator(); node = wxRichTextObjectList::compatibility_iterator(); @@ -7414,11 +7423,7 @@ wxRichTextImageBlock::wxRichTextImageBlock(const wxRichTextImageBlock& block):wx wxRichTextImageBlock::~wxRichTextImageBlock() { - if (m_data) - { - delete[] m_data; - m_data = NULL; - } + wxDELETEA(m_data); } void wxRichTextImageBlock::Init() @@ -7430,8 +7435,7 @@ void wxRichTextImageBlock::Init() void wxRichTextImageBlock::Clear() { - delete[] m_data; - m_data = NULL; + wxDELETEA(m_data); m_dataSize = 0; m_imageType = wxBITMAP_TYPE_INVALID; } @@ -7530,11 +7534,7 @@ bool wxRichTextImageBlock::Write(const wxString& filename) void wxRichTextImageBlock::Copy(const wxRichTextImageBlock& block) { m_imageType = block.m_imageType; - if (m_data) - { - delete[] m_data; - m_data = NULL; - } + wxDELETEA(m_data); m_dataSize = block.m_dataSize; if (m_dataSize == 0) return; @@ -7781,8 +7781,7 @@ bool wxRichTextBufferDataObject::GetDataHere(void *pBuf) const bool wxRichTextBufferDataObject::SetData(size_t WXUNUSED(len), const void *buf) { - delete m_richTextBuffer; - m_richTextBuffer = NULL; + wxDELETE(m_richTextBuffer); wxString bufXML((const char*) buf, wxConvUTF8); @@ -7793,8 +7792,7 @@ bool wxRichTextBufferDataObject::SetData(size_t WXUNUSED(len), const void *buf) { wxLogError(wxT("Could not read the buffer from an XML stream.\nYou may have forgotten to add the XML file handler.")); - delete m_richTextBuffer; - m_richTextBuffer = NULL; + wxDELETE(m_richTextBuffer); return false; }