diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-05-21 02:48:32 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-05-21 02:49:25 (GMT) |
commit | 54e9fdb0ddf673b3c8ee9a5ffce561114db2329c (patch) | |
tree | 0f0f7851cf3f9ed154898dd0f1ba733690bf4039 /src/declarative/util | |
parent | 58e154ec33ec1b1aea70fa35a1c5c692fe035df2 (diff) | |
download | Qt-54e9fdb0ddf673b3c8ee9a5ffce561114db2329c.zip Qt-54e9fdb0ddf673b3c8ee9a5ffce561114db2329c.tar.gz Qt-54e9fdb0ddf673b3c8ee9a5ffce561114db2329c.tar.bz2 |
Also show file/line numbers on XML query errors.
Task-number: QTBUG-10797
Reviewed-by: Bea Lam
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qdeclarativexmllistmodel.cpp | 20 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativexmllistmodel_p.h | 1 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 062e30e..9b8b26c 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -124,6 +124,7 @@ struct XmlQueryJob QString query; QString namespaces; QStringList roleQueries; + QList<void*> roleQueryErrorId; // the ptr to send back if there is an error QStringList keyRoleQueries; QStringList keyRoleResultsCache; }; @@ -167,6 +168,7 @@ public: continue; } job.roleQueries << roleObjects->at(i)->query(); + job.roleQueryErrorId << static_cast<void*>(roleObjects->at(i)); if (roleObjects->at(i)->isKey()) job.keyRoleQueries << job.roleQueries.last(); } @@ -182,6 +184,7 @@ public: Q_SIGNALS: void queryCompleted(const QDeclarativeXmlQueryResult &); + void error(void*, const QString&); protected: void run() { @@ -363,7 +366,7 @@ void QDeclarativeXmlQuery::doSubQueryJob() item = resultItems.next(); } } else { - qWarning().nospace() << "XmlListModel: invalid query: " << queries[i]; + emit error(job.roleQueryErrorId.at(i), queries[i]); } } //### should warn here if things have gone wrong. @@ -565,6 +568,8 @@ QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent) { connect(globalXmlQuery(), SIGNAL(queryCompleted(QDeclarativeXmlQueryResult)), this, SLOT(queryCompleted(QDeclarativeXmlQueryResult))); + connect(globalXmlQuery(), SIGNAL(error(void*,QString)), + this, SLOT(queryError(void*,QString))); } QDeclarativeXmlListModel::~QDeclarativeXmlListModel() @@ -959,6 +964,19 @@ void QDeclarativeXmlListModel::dataCleared() queryCompleted(r); } +void QDeclarativeXmlListModel::queryError(void* object, const QString& error) +{ + // Be extra careful, object may no longer exist, it's just an ID. + Q_D(QDeclarativeXmlListModel); + for (int i=0; i<d->roleObjects.count(); i++) { + if (d->roleObjects.at(i) == static_cast<QDeclarativeXmlListModelRole*>(object)) { + qmlInfo(d->roleObjects.at(i)) << QObject::tr("invalid query: \"%1\"").arg(error); + return; + } + } + qmlInfo(this) << QObject::tr("invalid query: \"%1\"").arg(error); +} + void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult &result) { Q_D(QDeclarativeXmlListModel); diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h index 4460f24..8d848c8 100644 --- a/src/declarative/util/qdeclarativexmllistmodel_p.h +++ b/src/declarative/util/qdeclarativexmllistmodel_p.h @@ -142,6 +142,7 @@ private Q_SLOTS: void requestProgress(qint64,qint64); void dataCleared(); void queryCompleted(const QDeclarativeXmlQueryResult &); + void queryError(void* object, const QString& error); private: Q_DECLARE_PRIVATE(QDeclarativeXmlListModel) |