QTextBrowser: do not try to open file with empty filename
When loading a resource from a href link, the link is not necessarily a local filename. In this case QTextBrowserPrivate::findFile() returns an empty filename which will create a warning when trying to open it. Task-number: QTBUG-43270 Change-Id: I39803afe3db9da0bfe2aaab86a5ebb6ed4b7c732 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
d12d7d3761
commit
b60b2c5fc5
|
|
@ -163,6 +163,9 @@ QString QTextBrowserPrivate::findFile(const QUrl &name) const
|
|||
fileName = name.toLocalFile();
|
||||
}
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return fileName;
|
||||
|
||||
if (QFileInfo(fileName).isAbsolute())
|
||||
return fileName;
|
||||
|
||||
|
|
@ -1089,6 +1092,8 @@ QVariant QTextBrowser::loadResource(int /*type*/, const QUrl &name)
|
|||
|
||||
QByteArray data;
|
||||
QString fileName = d->findFile(d->resolveUrl(name));
|
||||
if (fileName.isEmpty())
|
||||
return QVariant();
|
||||
QFile f(fileName);
|
||||
if (f.open(QFile::ReadOnly)) {
|
||||
data = f.readAll();
|
||||
|
|
|
|||
Loading…
Reference in New Issue