From 0e825cc599966f8c2b15fb02312c78862c21a1bb Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 22 Aug 2011 19:17:47 +0200 Subject: [PATCH] fix potential memory leak --- core/textpage.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/core/textpage.cpp b/core/textpage.cpp index 849a79557..e08db432b 100644 --- a/core/textpage.cpp +++ b/core/textpage.cpp @@ -1001,11 +1001,8 @@ static bool compareTinyTextEntityY(TinyTextEntity* first, TinyTextEntity* second */ void TextPagePrivate::copyFromList(const TextList &list) { - TextList::Iterator it = m_words.begin(), itEnd = m_words.end(); - for( ; it != itEnd ; it++) - { - m_words.erase(it); - } + qDeleteAll(m_words); + m_words.clear(); for(int i = 0 ; i < list.length() ; i++) { @@ -1019,11 +1016,8 @@ void TextPagePrivate::copyFromList(const TextList &list) */ void TextPagePrivate::copyToList(TextList &list) const { - TextList::Iterator it = list.begin(), itEnd = list.end(); - for( ; it != itEnd ; it++) - { - list.erase(it); - } + qDeleteAll(list); + list.clear(); for(int i = 0 ; i < m_words.length() ; i++) {