From d0d2b45a11a11190c5f75df3bbfebdb727e4dfbf Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 22 Aug 2011 20:29:36 +0200 Subject: [PATCH] Fix TextPagePrivate::removeSpace iteration You need to use the iterator returned by erase --- core/textpage.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/textpage.cpp b/core/textpage.cpp index 7bd1ec2c8..9143ee5da 100644 --- a/core/textpage.cpp +++ b/core/textpage.cpp @@ -1093,13 +1093,18 @@ void TextPagePrivate::removeSpace() const QString str(' '); it = m_words.begin(), itEnd = m_words.end(); - for( ; it != itEnd ; it++) + while ( it != itEnd ) { if((*it)->text() == str) { // create new Entity, otherwise there might be possible memory leakage m_spaces.append( new TinyTextEntity( (*it)->text(),(*it)->area ) ); - m_words.erase(it); + delete *it; + it = m_words.erase(it); + } + else + { + ++it; } } }