From: Václav Slavík Date: Mon, 18 Jun 2007 08:55:11 +0000 (+0000) Subject: fixed wxString iterators linked list corruption X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/300b44a9336a9610fef256afb412e8fb6b51840f fixed wxString iterators linked list corruption git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/string.h b/include/wx/string.h index 3296fb40f0..a715911343 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -390,6 +390,10 @@ struct WXDLLIMPEXP_BASE wxStringIteratorNode wxStringImpl::const_iterator *m_citer; wxStringImpl::iterator *m_iter; wxStringIteratorNode *m_prev, *m_next; + + // the node belongs to a particular iterator instance, it's not copied + // when a copy of the iterator is made + DECLARE_NO_COPY_CLASS(wxStringIteratorNode) }; #endif // wxUSE_UNICODE_UTF8 @@ -663,6 +667,8 @@ public: public: iterator(const iterator& i) : m_cur(i.m_cur), m_node(i.str(), &m_cur) {} + iterator& operator=(const iterator& i) + { m_cur = i.m_cur; return *this; } reference operator*() { return wxUniCharRef::CreateForString(m_node, m_cur); } @@ -699,6 +705,11 @@ public: const_iterator(const iterator& i) : m_cur(i.m_cur), m_node(i.str(), &m_cur) {} + const_iterator& operator=(const const_iterator& i) + { m_cur = i.m_cur; return *this; } + const_iterator& operator=(const iterator& i) + { m_cur = i.m_cur; return *this; } + reference operator*() const { return wxStringOperations::DecodeChar(m_cur); } @@ -2575,6 +2586,10 @@ private: { wxStringIteratorNodeHead() : ptr(NULL) {} wxStringIteratorNode *ptr; + + // copying is disallowed as it would result in more than one pointer into + // the same linked list + DECLARE_NO_COPY_CLASS(wxStringIteratorNodeHead) }; wxStringIteratorNodeHead m_iterators;