Skip to content

Commit

Permalink
Pass on local html links with a fragment to openUrl()
Browse files Browse the repository at this point in the history
If a file link to a html file has a fragment part included then this
will be lost when passed to QDesktopServices::openUrl() as this is not
kept in the conversion of the QUrl. So by checking the filename in the
case of a fragment existing in the url, we can be sure that the
information is passed on correctly for html files.

Task-number: QTBUG-14460
Change-Id: I8167d8c164713dd999603ba9e74150f4f1a4abea
Reviewed-by: David Faure <[email protected]>
  • Loading branch information
AndyShawQt committed Apr 6, 2018
1 parent ec23d96 commit d90fb72
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/util/qdesktopservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ bool QDesktopServices::openUrl(const QUrl &url)
qWarning("The platform plugin does not support services.");
return false;
}
return url.scheme() == QLatin1String("file") ?
platformServices->openDocument(url) : platformServices->openUrl(url);
// We only use openDocument if there is no fragment for the URL to
// avoid it being lost when using openDocument
if (url.isLocalFile() && !url.hasFragment())
return platformServices->openDocument(url);
return platformServices->openUrl(url);
}

/*!
Expand Down

0 comments on commit d90fb72

Please sign in to comment.