diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-06-01 03:06:05 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-06-01 03:06:05 (GMT) |
commit | 91cb226780d05f0f7d8fd1875121427ade52c1a8 (patch) | |
tree | d0e8764e164cfefb8c6c7b7d14502c48cb988a5a /src | |
parent | 41e4f2207008888803920df85cdaa6b0af31d428 (diff) | |
download | Qt-91cb226780d05f0f7d8fd1875121427ade52c1a8.zip Qt-91cb226780d05f0f7d8fd1875121427ade52c1a8.tar.gz Qt-91cb226780d05f0f7d8fd1875121427ade52c1a8.tar.bz2 |
Avoid refilling view during model change.
The view position is reset to 0 after clear()ing, but this results
in refill() being called, effectively undoing the clear(). Fix is to make
the model invalid before resetting position.
Task-number: QTBUG-11105
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 78c56d6..01928a1 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1466,13 +1466,15 @@ void QDeclarativeListView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); } d->clear(); + QDeclarativeVisualModel *oldModel = d->model; + d->model = 0; d->setPosition(0); d->modelVariant = model; QObject *object = qvariant_cast<QObject*>(model); QDeclarativeVisualModel *vim = 0; if (object && (vim = qobject_cast<QDeclarativeVisualModel *>(object))) { if (d->ownModel) { - delete d->model; + delete oldModel; d->ownModel = false; } d->model = vim; @@ -1480,6 +1482,8 @@ void QDeclarativeListView::setModel(const QVariant &model) if (!d->ownModel) { d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); d->ownModel = true; + } else { + d->model = oldModel; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) dataModel->setModel(model); |