summaryrefslogtreecommitdiff
path: root/src/corelib/kernel/qvariant.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-10-16 15:43:40 +0200
committerJędrzej Nowacki <jedrzej.nowacki@digia.com>2014-10-23 08:28:00 +0200
commitc399e4b7ea0b10dd7eb71ebe3ccea3c6134f25ba (patch)
treec0f6cc9b3a2973dfdd4eec1546cdb86466697b28 /src/corelib/kernel/qvariant.cpp
parent80ebedecf93d9494736448ac65d280c984f300b1 (diff)
downloadqtbase-c399e4b7ea0b10dd7eb71ebe3ccea3c6134f25ba.tar.gz
Q{Sequential,Associative}Iterable: fix const_iterator assignment
The code didn't properly clean up the current state before assigning the new state. Change-Id: If56cf43bace976203ff186759b2a81705b2b22d2 Reviewed-by: Stephen Kelly <steveire@gmail.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r--src/corelib/kernel/qvariant.cpp20
1 files 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;
}