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>
This commit is contained in:
Marc Mutz 2014-10-16 15:43:40 +02:00 committed by Jędrzej Nowacki
parent 80ebedecf9
commit c399e4b7ea

View File

@ -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;
}