Clear the root index when the model is reset.
Task-number: QTBUG-18839 Change-Id: I46608d7481d820fa74a9be60df1e018e70a761c6 Merge-request: 2598 Reviewed-by: Martin Jones <martin.jones@nokia.com> (cherry picked from commit f6b7ce204ee88be0fedb4cfcff382f208fa4ed33)
This commit is contained in:
parent
b2617d8096
commit
15407cfb5f
|
@ -1398,7 +1398,12 @@ void QDeclarativeVisualDataModel::_q_layoutChanged()
|
|||
|
||||
void QDeclarativeVisualDataModel::_q_modelReset()
|
||||
{
|
||||
Q_D(QDeclarativeVisualDataModel);
|
||||
d->m_root = QModelIndex();
|
||||
emit modelReset();
|
||||
emit rootIndexChanged();
|
||||
if (d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(d->m_root))
|
||||
d->m_abstractItemModel->fetchMore(d->m_root);
|
||||
}
|
||||
|
||||
void QDeclarativeVisualDataModel::_q_createdPackage(int index, QDeclarativePackage *package)
|
||||
|
|
|
@ -190,6 +190,11 @@ void tst_qdeclarativevisualdatamodel::rootIndex()
|
|||
QMetaObject::invokeMethod(obj, "setRootToParent");
|
||||
QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
|
||||
|
||||
QMetaObject::invokeMethod(obj, "setRoot");
|
||||
QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
|
||||
model.clear(); // will emit modelReset()
|
||||
QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue