diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index 132667c50c..84a1fd7002 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -4654,6 +4654,7 @@ protected: // The lines that make up the wrapped paragraph wxRichTextLineList m_cachedLines; + wxVector m_cachedLinesVect; // Whether the paragraph is impacted by floating objects from above int m_impactedByFloatingObjects; diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index b331564165..cbe9cf677a 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -5697,6 +5697,7 @@ void wxRichTextParagraph::Copy(const wxRichTextParagraph& obj) void wxRichTextParagraph::ClearLines() { WX_CLEAR_LIST(wxRichTextLineList, m_cachedLines); + m_cachedLinesVect.clear(); } /// Get/set the object size for the given range. Returns false if the range @@ -6529,7 +6530,8 @@ wxRichTextLine* wxRichTextParagraph::AllocateLine(int pos) { if (pos < (int) m_cachedLines.GetCount()) { - wxRichTextLine* line = m_cachedLines.Item(pos)->GetData(); + assert(m_cachedLinesVect.size() == m_cachedLines.GetCount()); + wxRichTextLine* line = m_cachedLinesVect[pos]; line->Init(this); return line; } @@ -6537,6 +6539,7 @@ wxRichTextLine* wxRichTextParagraph::AllocateLine(int pos) { wxRichTextLine* line = new wxRichTextLine(this); m_cachedLines.Append(line); + m_cachedLinesVect.push_back(line); return line; } } @@ -6555,6 +6558,7 @@ bool wxRichTextParagraph::ClearUnusedLines(int lineCount) delete line; } } + m_cachedLinesVect.resize(lineCount); return true; }