summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/xmlpatterns/data/qboolean.cpp2
-rw-r--r--tests/auto/qxmlquery/tst_qxmlquery.cpp18
-rw-r--r--tools/xmlpatterns/qcoloringmessagehandler.cpp12
3 files changed, 28 insertions, 4 deletions
diff --git a/src/xmlpatterns/data/qboolean.cpp b/src/xmlpatterns/data/qboolean.cpp
index 07562fd..bb4ece1 100644
--- a/src/xmlpatterns/data/qboolean.cpp
+++ b/src/xmlpatterns/data/qboolean.cpp
@@ -76,7 +76,7 @@ bool Boolean::evaluateEBV(const Item &first,
{
Q_ASSERT(context);
context->error(QtXmlPatterns::tr("Effective Boolean Value cannot be calculated for a sequence "
- "containing two or more atomic values."),
+ "containing two or more atomic values."),
ReportContext::FORG0006,
QSourceLocation());
return false;
diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp
index 28af641..b273311 100644
--- a/tests/auto/qxmlquery/tst_qxmlquery.cpp
+++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp
@@ -219,6 +219,7 @@ private Q_SLOTS:
void bindVariableQXmlNameQXmlQuerySignature() const;
void bindVariableQXmlNameQXmlQuery() const;
void bindVariableQXmlQueryInvalidate() const;
+ void unknownSourceLocation() const;
// TODO call all URI resolving functions where 1) the URI resolver return a null QUrl(); 2) resolves into valid, existing URI, 3) invalid, non-existing URI.
// TODO bind stringlists, variant lists, both ways.
@@ -3222,6 +3223,23 @@ void tst_QXmlQuery::bindVariableQXmlQueryInvalidate() const
QVERIFY(!query.isValid());
}
+void tst_QXmlQuery::unknownSourceLocation() const
+{
+ QBuffer b;
+ b.setData("<a><b/><b/></a>");
+ b.open(QIODevice::ReadOnly);
+
+ MessageSilencer silencer;
+ QXmlQuery query;
+ query.bindVariable(QLatin1String("inputDocument"), &b);
+ query.setMessageHandler(&silencer);
+
+ query.setQuery(QLatin1String("doc($inputDocument)/a/(let $v := b/string() return if ($v) then $v else ())"));
+
+ QString output;
+ query.evaluateTo(&output);
+}
+
QTEST_MAIN(tst_QXmlQuery)
#include "tst_qxmlquery.moc"
diff --git a/tools/xmlpatterns/qcoloringmessagehandler.cpp b/tools/xmlpatterns/qcoloringmessagehandler.cpp
index 9616097..0ddb246 100644
--- a/tools/xmlpatterns/qcoloringmessagehandler.cpp
+++ b/tools/xmlpatterns/qcoloringmessagehandler.cpp
@@ -100,12 +100,18 @@ void ColoringMessageHandler::handleMessage(QtMsgType type,
}
case QtFatalMsg:
{
- Q_ASSERT(!sourceLocation.isNull());
const QString errorCode(identifier.fragment());
Q_ASSERT(!errorCode.isEmpty());
QUrl uri(identifier);
uri.setFragment(QString());
+ QString location;
+
+ if(sourceLocation.isNull())
+ location = QXmlPatternistCLI::tr("Unknown location");
+ else
+ location = QString::fromLatin1(sourceLocation.uri().toEncoded());
+
QString errorId;
/* If it's a standard error code, we don't want to output the
* whole URI. */
@@ -117,7 +123,7 @@ void ColoringMessageHandler::handleMessage(QtMsgType type,
if(hasLine)
{
writeUncolored(QXmlPatternistCLI::tr("Error %1 in %2, at line %3, column %4: %5").arg(colorify(errorId, ErrorCode),
- colorify(QString::fromLatin1(sourceLocation.uri().toEncoded()), Location),
+ colorify(location, Location),
colorify(QString::number(sourceLocation.line()), Location),
colorify(QString::number(sourceLocation.column()), Location),
colorifyDescription(description)));
@@ -125,7 +131,7 @@ void ColoringMessageHandler::handleMessage(QtMsgType type,
else
{
writeUncolored(QXmlPatternistCLI::tr("Error %1 in %2: %3").arg(colorify(errorId, ErrorCode),
- colorify(QString::fromLatin1(sourceLocation.uri().toEncoded()), Location),
+ colorify(location, Location),
colorifyDescription(description)));
}
break;