aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qdeclarativelistcompositor.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-10-14 16:44:46 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-02 03:52:25 +0100
commit1c394490f4efe6055426257a8dfcec4cdf3e12af (patch)
tree029ccee9a19bf225dd148b347d52472f3c2f9ba8 /src/declarative/util/qdeclarativelistcompositor.cpp
parentc177691118e4e2bace9b5c1f4f57343190e6ad64 (diff)
Fix incorrect cache indexes when consecutive list items are removed.
When cached model items are removed listItemsRemoved will try and append a new cache only range onto a preceding one where possible. Previously it would then re-run that range so the current indexes in the list were incremented before moving onto the next range, which meant that the current indexes were incremented by size of the previous range twice. Instead of processing the range a second time increment the cache indexes directly when inserting a cache only range and move directly onto the next range in the list. Change-Id: I63418c4397f911cefb521c5a5b0dd25faf66e08b Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative/util/qdeclarativelistcompositor.cpp')
-rw-r--r--src/declarative/util/qdeclarativelistcompositor.cpp43
1 files changed, 6 insertions, 37 deletions
diff --git a/src/declarative/util/qdeclarativelistcompositor.cpp b/src/declarative/util/qdeclarativelistcompositor.cpp
index be0d543368..0618ed2b6e 100644
--- a/src/declarative/util/qdeclarativelistcompositor.cpp
+++ b/src/declarative/util/qdeclarativelistcompositor.cpp
@@ -154,22 +154,6 @@ static bool qt_verifyIntegrity(
//#define QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(args) qDebug() << m_end.index[1] << m_end.index[0] << Q_FUNC_INFO args;
#define QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(args)
-QDeclarativeListCompositor::iterator &QDeclarativeListCompositor::iterator::operator ++()
-{
- while (!(range->flags & groupFlag)) {
- incrementIndexes(range->count - offset);
- offset = 0;
- range = range->next;
- }
- incrementIndexes(1);
- if (++offset == range->count) {
- while (!((range = range->next)->flags & groupFlag))
- incrementIndexes(range->count);
- offset = 0;
- }
- return *this;
-}
-
QDeclarativeListCompositor::iterator &QDeclarativeListCompositor::iterator::operator +=(int difference)
{
Q_ASSERT(difference >= 0);
@@ -210,27 +194,10 @@ QDeclarativeListCompositor::iterator &QDeclarativeListCompositor::iterator::oper
return *this;
}
-QDeclarativeListCompositor::insert_iterator &QDeclarativeListCompositor::insert_iterator::operator ++()
-{
- while (!(range->flags & groupFlag)) {
- incrementIndexes(range->count - offset);
- offset = 0;
- range = range->next;
- }
- incrementIndexes(1);
- if (++offset == range->count && !range->append()) {
- while (!((range = range->next)->flags & groupFlag) ){
- incrementIndexes(range->count);
- }
- offset = 0;
- }
- return *this;
-}
-
QDeclarativeListCompositor::insert_iterator &QDeclarativeListCompositor::insert_iterator::operator +=(int difference)
{
Q_ASSERT(difference >= 0);
- while (!(range->flags & groupFlag) && range->flags & GroupMask) {
+ while (!(range->flags & groupFlag) && (range->flags & (GroupMask | CacheFlag))) {
incrementIndexes(range->count - offset);
offset = 0;
range = range->next;
@@ -252,7 +219,7 @@ QDeclarativeListCompositor::insert_iterator &QDeclarativeListCompositor::insert_
QDeclarativeListCompositor::insert_iterator &QDeclarativeListCompositor::insert_iterator::operator -=(int difference)
{
Q_ASSERT(difference >= 0);
- while (!(range->flags & groupFlag) && range->flags & GroupMask) {
+ while (!(range->flags & groupFlag) && (range->flags & (GroupMask | CacheFlag))) {
decrementIndexes(offset);
range = range->previous;
offset = range->count;
@@ -359,7 +326,7 @@ QDeclarativeListCompositor::insert_iterator QDeclarativeListCompositor::findInse
Q_ASSERT(index >=0 && index <= count(group));
insert_iterator it;
if (m_cacheIt == m_end) {
- m_cacheIt = iterator(m_ranges.next, 0, group, m_groupCount);
+ it = iterator(m_ranges.next, 0, group, m_groupCount);
it += index;
} else {
const int offset = index - m_cacheIt.index[group];
@@ -976,6 +943,7 @@ void QDeclarativeListCompositor::listItemsRemoved(
} else {
*it = insert(*it, it->list, -1, removeCount, CacheFlag)->next;
}
+ it.index[Cache] += removeCount;
}
if (removeFlags & GroupMask)
translatedRemovals->append(translatedRemoval);
@@ -994,10 +962,11 @@ void QDeclarativeListCompositor::listItemsRemoved(
&& it->list == it->next->list
&& (it->flags == CacheFlag || it->end() == it->next->index)
&& it->flags == (it->next->flags & ~AppendFlag)) {
+
+ it.index[Cache] += it->next->count;
it->count += it->next->count;
it->flags = it->next->flags;
erase(it->next);
- *it = it->previous;
} else if (!removed) {
it.incrementIndexes(it->count);
}