From c399e4b7ea0b10dd7eb71ebe3ccea3c6134f25ba Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 16 Oct 2014 15:43:40 +0200 Subject: Q{Sequential,Associative}Iterable: fix const_iterator assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code didn't properly clean up the current state before assigning the new state. Change-Id: If56cf43bace976203ff186759b2a81705b2b22d2 Reviewed-by: Stephen Kelly Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qvariant.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index cea893ba0c..2ac1bb11fb 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3632,11 +3632,13 @@ QSequentialIterable::const_iterator::const_iterator(const const_iterator &other) QSequentialIterable::const_iterator& QSequentialIterable::const_iterator::operator=(const const_iterator &other) { - if (!m_impl.equal(other.m_impl)) { - m_impl = other.m_impl; - ref = other.ref; + other.ref->ref(); + if (!ref->deref()) { + m_impl.destroyIter(); + delete ref; } - ref->ref(); + m_impl = other.m_impl; + ref = other.ref; return *this; } @@ -3941,11 +3943,13 @@ QAssociativeIterable::const_iterator::const_iterator(const const_iterator &other QAssociativeIterable::const_iterator& QAssociativeIterable::const_iterator::operator=(const const_iterator &other) { - if (!m_impl.equal(other.m_impl)) { - m_impl = other.m_impl; - ref = other.ref; + other.ref->ref(); + if (!ref->deref()) { + m_impl.destroyIter(); + delete ref; } - ref->ref(); + m_impl = other.m_impl; + ref = other.ref; return *this; } -- cgit v1.2.3