Stop stuffing the URL "<Unknown File>" in QML errors
authorThiago Macieira <thiago.macieira@intel.com>
Wed, 11 Apr 2012 18:57:06 +0000 (15:57 -0300)
committerQt by Nokia <qt-info@nokia.com>
Thu, 12 Apr 2012 03:02:33 +0000 (05:02 +0200)
QQmlError already knows how to deal with source scripts with no URL
and it will use "<Unknown File>" when converting to a string.

QUrl in Qt 5 leaves the "<" and ">" characters encoded, which means we
ended up getting warnings about "%3CUnknown File%3E", which isn't
nice.

Change-Id: I504604fa37bb734549048432aaf9db3b1fa568d2
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>

src/qml/qml/qqmlbinding.cpp
src/qml/qml/qqmljavascriptexpression.cpp
src/qml/qml/v8/qv8bindings.cpp
tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
tests/auto/qml/qqmlengine/tst_qqmlengine.cpp

index c4f48ef..d2a02dc 100644 (file)
@@ -230,8 +230,6 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags)
                 if (needsErrorData) {
                     QUrl url = QUrl(m_url);
 
-                    if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
-
                     delayedError()->error.setUrl(url);
                     delayedError()->error.setLine(m_lineNumber);
                     delayedError()->error.setColumn(m_columnNumber);
index aad6a04..569a292 100644 (file)
@@ -263,7 +263,7 @@ void QQmlJavaScriptExpression::exceptionToError(v8::Handle<v8::Message> message,
 
     v8::Local<v8::String> file = name->IsString()?name->ToString():v8::Local<v8::String>();
     if (file.IsEmpty() || file->Length() == 0)
-        error.setUrl(QUrl(QLatin1String("<Unknown File>")));
+        error.setUrl(QUrl());
     else
         error.setUrl(QUrl(QV8Engine::toStringStatic(file)));
 
index 025854f..65c395e 100644 (file)
@@ -144,10 +144,7 @@ void QV8Bindings::Binding::update(QQmlPropertyPrivate::WriteFlags flags)
         if (!watcher.wasDeleted() && !destroyedFlag()) {
 
             if (needsErrorData) {
-                QUrl url = parent->url();
-                if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
-
-                delayedError()->error.setUrl(url);
+                delayedError()->error.setUrl(parent->url());
                 delayedError()->error.setLine(instruction->line);
                 delayedError()->error.setColumn(-1);
             }
index 6525bde..16365ee 100644 (file)
@@ -345,7 +345,7 @@ void tst_qqmlcontext::setContextProperty()
         QQmlContext ctxt(engine.rootContext());
         ctxt.setContextProperty("ctxtProp", QVariant());
 
-        QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Cannot read property 'a' of undefined");
+        QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: TypeError: Cannot read property 'a' of undefined");
         QObject *obj = component.create(&ctxt);
 
         QVariant v = obj->property("obj");
index af2c897..89fc8e0 100644 (file)
@@ -268,7 +268,7 @@ void tst_qqmlengine::outputWarningsToStandardError()
     delete o;
 
     QCOMPARE(warnings.count(), 1);
-    QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int"));
+    QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>: Unable to assign [undefined] to int"));
     warnings.clear();