Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
5.15.2
-
None
-
Ubuntu22
Description
With assistant 5.15.3 in Ubuntu22 we cannot open PDF-files from a `qthelp://`-URL. They are either displayed as binary text within the assistant or we get prompted a "policy changed" error (WebKit 102). The root cause is that the QDesktopServices::openUrl mechanism which should handle local URLs like `qthelp://` is never called due to a bug in the code.
The bug is still present in the HEAD version of `helpviewer.cpp`
https://github.com/qt/qttools/blob/dev/src/assistant/assistant/helpviewer.cpp
bool HelpViewer::launchWithExternalApp(const QUrl &url) { TRACE_OBJ if (isLocalUrl(url)) { const HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); const QUrl &resolvedUrl = helpEngine.findFile(url); if (!resolvedUrl.isValid()) return false; const QString& path = resolvedUrl.toLocalFile(); if (!canOpenPage(path)) {
´helpEngine.findFile` typically does not alter or solve the URL (to a file path) but returns it unaltered. This can also be seen in the docstring of `helpEngine.findFile`:
/*! Returns an invalid URL if the file \a url cannot be found. If the file exists, either the same url is returned or a different url if the file is located in a different namespace which is merged via a common virtual folder. */
Therefore `resolvedUrl` is a `qthelp://...`-URL and calling `toLocalFile();` on it simply returns an empty string. The empty string will always return `true` for `canOpenPage`. Thus the if-block below is never entered and assistant never calls `QDesktopServices::openUrl` to open the PDF file.
The solution is to fix the code as following:
const QString& path = resolvedUrl.path();