aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2014-07-11 16:15:01 +0200
committerDavid Faure <david.faure@kdab.com>2014-07-24 15:15:43 +0200
commitaad255f6d5e79f496e93c9e758504a1d2c8a2467 (patch)
tree02a1b6f1225b985bcd9b42e593203d18d0cfce0a /src
parenta38b0863f88bc89733c213cf6f73abc7ed15bd5a (diff)
QQmlError::toString: improve handling of empty urls.
"file::2:23: ..." is strange to read. Show "<Unknown File>:2:23: ..." instead, by treating empty urls (including "file:") as unknown, and by still showing line and column numbers in such a case. This change makes it possible for QUrl::fromLocalFile("") to return an empty url rather than "file:", which this module was relying upon in the tests. Change-Id: I91918090fd4e0aa9a25dbbb18893a0ce94140e21 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlerror.cpp11
-rw-r--r--src/qml/qml/qqmlinfo.cpp2
2 files changed, 7 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp
index c583156c43..6d72bfcffa 100644
--- a/src/qml/qml/qqmlerror.cpp
+++ b/src/qml/qml/qqmlerror.cpp
@@ -249,16 +249,17 @@ QString QQmlError::toString() const
QUrl u(url());
int l(line());
- if (u.isEmpty()) {
+ if (u.isEmpty() || (u.isLocalFile() && u.path().isEmpty()))
rv = QLatin1String("<Unknown File>");
- } else if (l != -1) {
- rv = u.toString() + QLatin1Char(':') + QString::number(l);
+ else
+ rv = u.toString();
+
+ if (l != -1) {
+ rv += QLatin1Char(':') + QString::number(l);
int c(column());
if (c != -1)
rv += QLatin1Char(':') + QString::number(c);
- } else {
- rv = u.toString();
}
rv += QLatin1String(": ") + description();
diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp
index 63ce2d419c..2f013863ca 100644
--- a/src/qml/qml/qqmlinfo.cpp
+++ b/src/qml/qml/qqmlinfo.cpp
@@ -147,7 +147,7 @@ QQmlInfo::~QQmlInfo()
d->buffer.prepend(QLatin1String("QML ") + typeName + QLatin1String(": "));
QQmlData *ddata = QQmlData::get(object, false);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) {
+ if (ddata && ddata->outerContext) {
error.setUrl(ddata->outerContext->url);
error.setLine(ddata->lineNumber);
error.setColumn(ddata->columnNumber);