Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113143

QGenericUnixServices::openDocument / xdgDesktopPortalOpenFile fails in flatpak

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.5.2, 6.6.0
    • 6.4.3
    • QPA: X11/XCB
    • Linux/Wayland
    • 03cbcba7b (dev), 43cd15131 (6.5)

      This bug seems related to QTBUG-83939 , but concerns flatpak, (QTBUG-83939 concerns snaps).

      When I try to open a html file that resides within the flatpak with QDesktopServices::openUrl(), it fails silently. As a workaround I call /usr/bin/xdg-open <url>, which works.

      I confirmed that xdgDesktopPortalOpenFile(const QUrl &url) gets called with a expected but fails to open the file. It seems no error is generated.

      My code, including the workaround, looks like this (the complete cpp file of the project can be found here: https://github.com/ChrisHal/PMbrowser/blob/db2bc698cae45e25b19b6795cef4b73fe0e40c84/QtPMbrowser/pmbrowserwindow.cpp#L1080): 

      void PMbrowserWindow::openHelp()
      {
      #ifdef _linux_
      if (help_url.isLocalFile() && QFile::exists("/.flatpak-info"))

      { QString u = help_url.toEncoded(); QStringList a; a.append(u); auto res = QProcess::startDetached("/usr/bin/xdg-open", a); assert(res); (void)res; return; }

      #endif
      if (!QDesktopServices::openUrl(help_url) && help_url.isLocalFile()) {
      // we should only get here when trying to
      // open a local file from within a flatpak sandbox
      auto res = QMessageBox::question(this, "Error",
      "Could not open local help url.\nDo you want to try the online help instead?");
      if (res == QMessageBox::Yes)

      { QDesktopServices::openUrl(QString(PROJECT_HOMEPAGE)); }

      }
      }

      A fix for this bug would be appreciated.

        1. dbus-mon-buggy.txt
          4 kB
        2. dbus-mon-withFix.txt
          5 kB
        3. fix_qtbug_113143.cpp
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            jgrulich Jan Grulich
            chrishal Christian Halaszovich
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes