Correctly resolve qrc:/ URLs in type loading
authorMatthew Vogt <matthew.vogt@nokia.com>
Fri, 22 Jun 2012 06:28:40 +0000 (16:28 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 25 Jun 2012 05:29:12 +0000 (07:29 +0200)
URLS specified with the qrc scheme do not use the 'authority'
part of the syntax, and therefore do not necessarily contain a
double slash immediately after the scheme.

Task-number: QTBUG-25937

Change-Id: I49156b463f11dbb38d6a01d30ea934b0a652c8e5
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/qml/qml/qqmlfile.cpp
tests/auto/qml/qml.pro
tests/auto/qml/qrcqml/tst_qrcqml.cpp

index b0da80f..df876b6 100644 (file)
@@ -51,7 +51,7 @@
 \class QQmlFile
 \brief The QQmlFile class gives access to local and remote files.
 
-Supports file://, qrc://, bundle:// uris and whatever QNetworkAccessManager supports.
+Supports file://, qrc:/, bundle:// uris and whatever QNetworkAccessManager supports.
 */
 
 #define QQMLFILE_MAX_REDIRECT_RECURSION 16
@@ -481,7 +481,7 @@ bool QQmlFile::connectDownloadProgress(QObject *object, int method)
 /*!
 Returns true if QQmlFile will open \a url synchronously.
 
-Synchronous urls have a qrc://, file://, or bundle:// scheme.
+Synchronous urls have a qrc:/, file://, or bundle:// scheme.
 */
 bool QQmlFile::isSynchronous(const QUrl &url)
 {
@@ -498,11 +498,11 @@ bool QQmlFile::isSynchronous(const QUrl &url)
 /*!
 Returns true if QQmlFile will open \a url synchronously.
 
-Synchronous urls have a qrc://, file://, or bundle:// scheme.
+Synchronous urls have a qrc:/, file://, or bundle:// scheme.
 */
 bool QQmlFile::isSynchronous(const QString &url)
 {
-    if (url.length() < 6 /* qrc:// */)
+    if (url.length() < 5 /* qrc:/ */)
         return false;
 
     QChar f = url[0];
@@ -521,9 +521,9 @@ bool QQmlFile::isSynchronous(const QString &url)
 
     } else if (f == QLatin1Char('q') || f == QLatin1Char('Q')) {
 
-        return url.length() >= 6 /* bundle:// */ &&
+        return url.length() >= 5 /* qrc:/ */ &&
                url.startsWith(qrc_string, Qt::CaseInsensitive) &&
-               url[3] == QLatin1Char(':') && url[4] == QLatin1Char('/') && url[5] == QLatin1Char('/');
+               url[3] == QLatin1Char(':') && url[4] == QLatin1Char('/');
 
     }
 
@@ -556,7 +556,7 @@ bool QQmlFile::isBundle(const QUrl &url)
 /*!
 Returns true if \a url is a local file that can be opened with QFile.
 
-Local file urls have either a qrc:// or file:// scheme.
+Local file urls have either a qrc:/ or file:// scheme.
 */
 bool QQmlFile::isLocalFile(const QUrl &url)
 {
@@ -572,11 +572,11 @@ bool QQmlFile::isLocalFile(const QUrl &url)
 /*!
 Returns true if \a url is a local file that can be opened with QFile.
 
-Local file urls have either a qrc:// or file:// scheme.
+Local file urls have either a qrc:/ or file:// scheme.
 */
 bool QQmlFile::isLocalFile(const QString &url)
 {
-    if (url.length() < 6 /* qrc:// */)
+    if (url.length() < 5 /* qrc:/ */)
         return false;
 
     QChar f = url[0];
@@ -589,9 +589,9 @@ bool QQmlFile::isLocalFile(const QString &url)
 
     } else if (f == QLatin1Char('q') || f == QLatin1Char('Q')) {
 
-        return url.length() >= 6 /* bundle:// */ &&
+        return url.length() >= 5 /* qrc:/ */ &&
                url.startsWith(qrc_string, Qt::CaseInsensitive) &&
-               url[3] == QLatin1Char(':') && url[4] == QLatin1Char('/') && url[5] == QLatin1Char('/');
+               url[3] == QLatin1Char(':') && url[4] == QLatin1Char('/');
 
     }
 
index e41c261..48613a4 100644 (file)
@@ -46,6 +46,7 @@ PRIVATETESTS += \
     qquicklistmodelworkerscript \
     qquickworkerscript \
     qqmlbundle \
+    qrcqml \
     v4
 
 !contains(QT_CONFIG, no-widgets) {
index f5d7dd5..b81fff0 100644 (file)
@@ -66,9 +66,6 @@ void tst_qrcqml::basicLoad()
 {
     QQmlEngine e;
     QQmlComponent c(&e, QUrl("qrc:/main.qml"));
-    if (c.isError())
-        qDebug() << "Error: " << c.errors();
-    QEXPECT_FAIL("", "QTBUG-25937", Abort);
     QVERIFY(c.isReady());
     QObject* o = c.create();
     QVERIFY(o);