From ea0cb11dc547c3b8a03618d31e4f7a85304f8fe3 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Wed, 27 Jul 2011 12:07:42 +1000 Subject: [PATCH] XmlListModel.status is Ready right after creation (should be Null) And whenever both the source the xml properties are empty, the status should be Null as well. Change-Id: I62936d9389b524833422a871b596b99cc93cc734 Task-number:QTBUG-18724 Reviewed-by:Michael Brasser Reviewed-on: http://codereview.qt.nokia.com/2231 Reviewed-by: Michael Brasser --- src/declarative/util/qdeclarativexmllistmodel.cpp | 5 ++++- .../qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index e129596..5b978f4 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -1018,7 +1018,10 @@ void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult & d->size = result.size; d->data = result.data; d->keyRoleResultsCache = result.keyRoleResultsCache; - d->status = Ready; + if (d->src.isEmpty() && d->xml.isEmpty()) + d->status = Null; + else + d->status = Ready; d->errorString.clear(); d->queryId = -1; diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 37bafeb..2a1d716 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -390,7 +390,10 @@ void tst_qdeclarativexmllistmodel::xml() QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + if (xml.isEmpty()) + QCOMPARE(model->status(), QDeclarativeXmlListModel::Null); + else + QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->count(), count); @@ -452,6 +455,8 @@ void tst_qdeclarativexmllistmodel::source() QCOMPARE(model->count(), 9); model->setSource(source); + if (model->source().isEmpty()) + QCOMPARE(model->status(), QDeclarativeXmlListModel::Null); QCOMPARE(model->progress(), qreal(0.0)); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); @@ -521,7 +526,8 @@ void tst_qdeclarativexmllistmodel::data() void tst_qdeclarativexmllistmodel::get() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/get.qml")); - QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); QVERIFY(QMetaObject::invokeMethod(model, "runPreTest")); -- 2.7.4