aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-11-04 13:43:15 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-04 07:00:54 +0100
commitb2ead4c58908968a7c4885751360fa7ed2b58369 (patch)
treef66bd6de66cf6d44f5ecdc7620e229d3cc7eaf57 /src
parent1e542c8cd2fdd167c2b20a955034b0afe3b7268b (diff)
Fix invalid remove cache indexes caused by consecutive ranges.
listItemsRemoved attempts to merge and consecutive cache only ranges it produces, this same logic would also merge other consecutive ranges incorrectly incrementing the cacheIndex in the process. Since listItemsRemoved won't produce these consecutive ranges itself handle only the cache only ranges there and compress the other consecutive ranges where they originate. Change-Id: If4d95fb741c8e7003ed48bfb2559c30c948c255b Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativelistcompositor.cpp44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/declarative/util/qdeclarativelistcompositor.cpp b/src/declarative/util/qdeclarativelistcompositor.cpp
index 0618ed2b6e..b8b4dbf054 100644
--- a/src/declarative/util/qdeclarativelistcompositor.cpp
+++ b/src/declarative/util/qdeclarativelistcompositor.cpp
@@ -55,7 +55,7 @@ static bool qt_verifyMinimal(
bool minimal = true;
int index = 0;
- for (const QDeclarativeListCompositor::Range *range = begin->next; range != end; range = range->next, ++index) {
+ for (const QDeclarativeListCompositor::Range *range = begin->next; range != *end; range = range->next, ++index) {
if (range->previous->list == range->list
&& range->previous->flags == (range->flags & ~QDeclarativeListCompositor::AppendFlag)
&& range->previous->end() == range->index) {
@@ -456,7 +456,12 @@ void QDeclarativeListCompositor::setFlags(
from->previous->flags |= AppendFlag;
*from = erase(*from)->previous;
continue;
+ } else {
+ break;
}
+ } else if (!insertFlags) {
+ from.incrementIndexes(from->count - difference);
+ continue;
} else if (difference < from->count) {
*from = insert(*from, from->list, from->index, difference, setFlags)->next;
from->index += difference;
@@ -674,6 +679,16 @@ void QDeclarativeListCompositor::move(
if (fromIt->append())
fromIt->previous->flags |= AppendFlag;
*fromIt = erase(*fromIt);
+
+ if (*fromIt != m_ranges.next && fromIt->flags == PrependFlag
+ && fromIt->previous != &m_ranges
+ && fromIt->previous->flags == PrependFlag
+ && fromIt->previous->list == fromIt->list
+ && fromIt->previous->end() == fromIt->index) {
+ fromIt.incrementIndexes(fromIt->count);
+ fromIt->previous->count += fromIt->count;
+ *fromIt = erase(*fromIt);
+ }
} else if (count > 0) {
*fromIt = fromIt->next;
}
@@ -797,6 +812,14 @@ void QDeclarativeListCompositor::listItemsInserted(
}
if ((it->flags & ~AppendFlag) == flags) {
it->count += insertion.count;
+ } else if (offset == 0
+ && it->previous != &m_ranges
+ && it->previous->list == list
+ && it->previous->end() == insertion.index
+ && it->previous->flags == flags) {
+ it->previous->count += insertion.count;
+ it->index += insertion.count;
+ it.incrementIndexes(insertion.count);
} else {
if (offset > 0) {
it.incrementIndexes(offset);
@@ -956,16 +979,22 @@ void QDeclarativeListCompositor::listItemsRemoved(
}
} else if (relativeIndex < 0) {
it->index -= itemsRemoved;
+
+ if (it->previous != &m_ranges
+ && it->previous->list == it->list
+ && it->previous->end() == it->index
+ && it->previous->flags == (it->flags & ~AppendFlag)) {
+ it->previous->count += it->count;
+ it->previous->flags = it->flags;
+ it.incrementIndexes(it->count);
+ *it = erase(*it);
+ removed = true;
+ }
}
}
- if (it->next != &m_ranges
- && it->list == it->next->list
- && (it->flags == CacheFlag || it->end() == it->next->index)
- && it->flags == (it->next->flags & ~AppendFlag)) {
-
+ if (it->flags == CacheFlag && it->next->flags == CacheFlag && it->next->list == it->list) {
it.index[Cache] += it->next->count;
it->count += it->next->count;
- it->flags = it->next->flags;
erase(it->next);
} else if (!removed) {
it.incrementIndexes(it->count);
@@ -994,7 +1023,6 @@ void QDeclarativeListCompositor::listItemsMoved(
QVector<Remove> *translatedRemovals,
QVector<Insert> *translatedInsertions)
{
-
QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << from << to << count)
Q_ASSERT(count >= 0);