diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-05-21 01:12:23 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-05-21 01:17:52 (GMT) |
commit | 58e154ec33ec1b1aea70fa35a1c5c692fe035df2 (patch) | |
tree | 91afa6e0615e1b80861968f68d8701eaa0caeb22 | |
parent | 7e1f42ea22e34e5c846f518265c1ea864746587e (diff) | |
download | Qt-58e154ec33ec1b1aea70fa35a1c5c692fe035df2.zip Qt-58e154ec33ec1b1aea70fa35a1c5c692fe035df2.tar.gz Qt-58e154ec33ec1b1aea70fa35a1c5c692fe035df2.tar.bz2 |
Print warnings for xml query syntax errors
Task-number: QTBUG-10797
-rw-r--r-- | src/declarative/util/qdeclarativexmllistmodel.cpp | 17 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 4d91acc..062e30e 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -128,7 +128,6 @@ struct XmlQueryJob QStringList keyRoleResultsCache; }; - class QDeclarativeXmlQuery : public QThread { Q_OBJECT @@ -355,12 +354,16 @@ void QDeclarativeXmlQuery::doSubQueryJob() QList<QVariant> resultList; if (!queries[i].isEmpty()) { subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + queries[i] + QLatin1String(" return if ($v) then ") + queries[i] + QLatin1String(" else \"\")")); - QXmlResultItems resultItems; - subquery.evaluateTo(&resultItems); - QXmlItem item(resultItems.next()); - while (!item.isNull()) { - resultList << item.toAtomicValue(); //### we used to trim strings - item = resultItems.next(); + if (subquery.isValid()) { + QXmlResultItems resultItems; + subquery.evaluateTo(&resultItems); + QXmlItem item(resultItems.next()); + while (!item.isNull()) { + resultList << item.toAtomicValue(); //### we used to trim strings + item = resultItems.next(); + } + } else { + qWarning().nospace() << "XmlListModel: invalid query: " << queries[i]; } } //### should warn here if things have gone wrong. diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index e1dd6f4..464f9e0 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -224,6 +224,8 @@ void tst_qdeclarativexmllistmodel::roleErrors() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml")); QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, "XmlListModel: invalid query: \"age/\""); + //### make sure we receive all expected warning messages. QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); |