Correctly locate files with relative paths
authorLars Knoll <lars.knoll@nokia.com>
Fri, 4 May 2012 09:21:49 +0000 (11:21 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 5 Jun 2012 11:40:00 +0000 (13:40 +0200)
QUrl("relativefilename").toLocalFile() changed behavior
and now returns an empty string if the scheme is not set.
Setting the scheme to "file:" in setSource would however
break some other assumptions in the code about relative
url's.

Task-number: QTBUG-22416
Change-Id: I1b3fcbef81f6e356935ec426903989e783ce9a78
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/widgets/widgets/qtextbrowser.cpp
tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp

index b8ffced..c6b1a6d 100644 (file)
@@ -153,6 +153,8 @@ QString QTextBrowserPrivate::findFile(const QUrl &name) const
     QString fileName;
     if (name.scheme() == QLatin1String("qrc"))
         fileName = QLatin1String(":/") + name.path();
+    else if (name.scheme().isEmpty())
+        fileName = name.path();
     else
         fileName = name.toLocalFile();
 
index 8d4238b..e539224 100644 (file)
@@ -250,8 +250,6 @@ void tst_QTextBrowser::viewportPositionInHistory()
 
 void tst_QTextBrowser::relativeLinks()
 {
-    QEXPECT_FAIL("", "QTBUG-22416: First call to QTextBrowser::setSource fails unless URL created with QUrl::fromLocalFile", Abort);
-
     qRegisterMetaType<QUrl>("QUrl");
     QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(const QUrl &)));
     browser->setSource(QUrl("subdir/../qtextbrowser.html"));