summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2011-11-01 16:10:02 +0100
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 12:25:08 +0200
commit78043b57ac50a399222221fb8fad2a47ff90a10c (patch)
tree182603bab45ba66c086658a48e063df96b173dc5
parent45bdaac4636b69ddbae446ec65082a90290dda52 (diff)
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 feca6b5ca0..6a2816a2ad 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();