summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2011-11-01 15:10:02 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:25:08 (GMT)
commit78043b57ac50a399222221fb8fad2a47ff90a10c (patch)
tree182603bab45ba66c086658a48e063df96b173dc5
parent45bdaac4636b69ddbae446ec65082a90290dda52 (diff)
downloadQt-78043b57ac50a399222221fb8fad2a47ff90a10c.zip
Qt-78043b57ac50a399222221fb8fad2a47ff90a10c.tar.gz
Qt-78043b57ac50a399222221fb8fad2a47ff90a10c.tar.bz2
Ensure that using multiple GridViews with the same model source works
When the same model source is used in multiple GridViews then it can get into a state where items that have been inserted are removed from a list which it then later tries to access to emit signals for. This patch ensures that a list of the items that the signal is emitted for is kept before any of the wrapper items are potentially deleted so that the signals can be emitted as expected correctly. Task-number: QTBUG-22271
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index feca6b5..6a2816a 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -2885,6 +2885,10 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
}
}
+ QList<QDeclarativeGridViewAttached *> addedItems;
+ for (int j = 0; j < added.count(); ++j)
+ addedItems << added.at(j)->attached;
+
if (d->itemCount && d->currentIndex >= modelIndex) {
// adjust current item index
d->currentIndex += count;
@@ -2898,8 +2902,8 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
}
// everything is in order now - emit add() signal
- for (int j = 0; j < added.count(); ++j)
- added.at(j)->attached->emitAdd();
+ for (int j = 0; j < addedItems.count(); ++j)
+ addedItems.at(j)->emitAdd();
d->itemCount += count;
emit countChanged();