summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-08-27 07:07:12 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-08-27 07:07:12 (GMT)
commitf80f58b857d1fa9ad53ba6780daaaafa1c4b1111 (patch)
treedec4f6853ca8f8d17bbbf299c23cf640f99a61d5
parent84ab1ebab17e62176db1120845d0a3ece5cf9d80 (diff)
downloadQt-f80f58b857d1fa9ad53ba6780daaaafa1c4b1111.zip
Qt-f80f58b857d1fa9ad53ba6780daaaafa1c4b1111.tar.gz
Qt-f80f58b857d1fa9ad53ba6780daaaafa1c4b1111.tar.bz2
Make sure current item is released when removed but not visible.
-rw-r--r--src/declarative/fx/qfxgridview.cpp5
-rw-r--r--src/declarative/fx/qfxlistview.cpp6
2 files changed, 7 insertions, 4 deletions
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index b429895..bf6e863 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -1254,6 +1254,7 @@ void QFxGridView::itemsInserted(int modelIndex, int count)
void QFxGridView::itemsRemoved(int modelIndex, int count)
{
Q_D(QFxGridView);
+ bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
int index = d->mapFromModel(modelIndex);
if (index == -1) {
if (modelIndex + count - 1 < d->visibleIndex) {
@@ -1269,7 +1270,7 @@ void QFxGridView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ } else if (currentRemoved) {
// current item has been removed.
d->releaseItem(d->currentItem);
d->currentItem = 0;
@@ -1311,7 +1312,7 @@ void QFxGridView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ } else if (currentRemoved) {
// current item has been removed.
d->releaseItem(d->currentItem);
d->currentItem = 0;
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 0dfdce8..c1e03dd 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -1522,6 +1522,7 @@ void QFxListView::itemsRemoved(int modelIndex, int count)
{
Q_D(QFxListView);
d->updateUnrequestedIndexes();
+ bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
if (!d->mapRangeFromModel(modelIndex, count)) {
if (modelIndex + count - 1 < d->visibleIndex) {
// Items removed before our visible items.
@@ -1536,7 +1537,7 @@ void QFxListView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ } else if (currentRemoved) {
// current item has been removed.
d->releaseItem(d->currentItem);
d->currentItem = 0;
@@ -1579,8 +1580,9 @@ void QFxListView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ } else if (currentRemoved) {
// current item has been removed.
+ d->currentItem->attached->setIsCurrentItem(false);
d->releaseItem(d->currentItem);
d->currentItem = 0;
d->currentIndex = -1;