Correctly locate files with relative paths

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>
This commit is contained in:
Lars Knoll 2012-05-04 11:21:49 +02:00 committed by Qt by Nokia
parent fb631d10d0
commit 143daa6ac2
2 changed files with 2 additions and 2 deletions

View 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();

View 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"));