Fix moving mixed visible and non-visible View items.
authorAndrew den Exter <andrew.den-exter@nokia.com>
Wed, 4 Jan 2012 07:55:26 +0000 (17:55 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 4 Jan 2012 09:22:53 +0000 (10:22 +0100)
A removal for a move that included both cached and non-cached was
only evaluating the first part of the removal and skipping the
remainder.

Don't skip all subsequent removals when two ranges are merged, instead
reset the current indexes to the start of the merged range and continue
on as normal.

Task-number: QTBUG-23432
Change-Id: Ieda49e2f68cd0bbbd31ba1e7dfd5af7c3e350d78
Reviewed-by: Bea Lam <bea.lam@nokia.com>
src/quick/util/qdeclarativelistcompositor.cpp
tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp

index 8dca915..c1c31c7 100644 (file)
@@ -997,11 +997,10 @@ void QDeclarativeListCompositor::listItemsRemoved(
                         && it->previous->list == it->list
                         && it->previous->end() == it->index
                         && it->previous->flags == (it->flags & ~AppendFlag)) {
+                    it.decrementIndexes(it->previous->count);
                     it->previous->count += it->count;
                     it->previous->flags = it->flags;
-                    it.incrementIndexes(it->count);
                     *it = erase(*it)->previous;
-                    removed = true;
                 }
             }
         }
index edceff2..f59a194 100644 (file)
@@ -1501,6 +1501,25 @@ void tst_qdeclarativelistcompositor::listItemsMoved_data()
                 << IndexArray(defaultIndexes)
                 << IndexArray()
                 << IndexArray(selectionIndexes);
+    } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4,5,8,9};
+        static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11};
+        QTest::newRow("move mixed cached items")
+                << (RangeList()
+                    << Range(a,  0,  1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+                    << Range(a,  1,  2, C::PrependFlag | C::DefaultFlag)
+                    << Range(a,  3,  7, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+                    << Range(a, 10,  2, C::PrependFlag | C::DefaultFlag))
+                << a << 1 << 6 << 3
+                << (RemoveList()
+                    << Remove(0, 0, 1, 1, 2, C::PrependFlag | C::DefaultFlag, 0)
+                    << Remove(0, 0, 1, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
+                << (InsertList()
+                    << Insert(0, 0, 6, 6, 2, C::PrependFlag | C::DefaultFlag, 0)
+                    << Insert(0, 0, 8, 6, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
+                << IndexArray(cacheIndexes)
+                << IndexArray(defaultIndexes)
+                << IndexArray()
+                << IndexArray();
     }
 }