diff options
author | Ilya Fedin <fedin-ilja2010@ya.ru> | 2021-09-29 13:08:10 +0400 |
---|---|---|
committer | Ilya Fedin <fedin-ilja2010@ya.ru> | 2021-10-07 01:54:36 +0400 |
commit | 62a81bddfa13b169e3e31174f22546afc3d211f1 (patch) | |
tree | 310da61d30d1be6f6bf7a85faa20e4bbf96190d4 /src/gui/platform | |
parent | 46fc01d7ca10ab95e53206077c7c710d2032b4f0 (diff) |
Always fallback opening URLs to the regular way if portal fails
Even if the code fails, the runtime will have a xdg-open binary
that supports the required API (portals in flatpak and userd launcher
in snap)
Task-number: QTBUG-83939
Change-Id: I8527cfe20411c535686b7171ff9ef285ab9e10aa
Reviewed-by: Jan Grulich <jgrulich@redhat.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/platform')
-rw-r--r-- | src/gui/platform/unix/qgenericunixservices.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/gui/platform/unix/qgenericunixservices.cpp b/src/gui/platform/unix/qgenericunixservices.cpp index e52a0dbc8e..0fcc7ab44c 100644 --- a/src/gui/platform/unix/qgenericunixservices.cpp +++ b/src/gui/platform/unix/qgenericunixservices.cpp @@ -186,14 +186,6 @@ static inline bool checkNeedPortalSupport() return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty() || qEnvironmentVariableIsSet("SNAP"); } -static inline bool isPortalReturnPermanent(const QDBusError &error) -{ - // A service unknown error isn't permanent, it just indicates that we - // should fall back to the regular way. This check includes - // QDBusError::NoError. - return error.type() != QDBusError::ServiceUnknown && error.type() != QDBusError::AccessDenied; -} - static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url) { // DBus signature: @@ -312,8 +304,8 @@ bool QGenericUnixServices::openUrl(const QUrl &url) #if QT_CONFIG(dbus) if (checkNeedPortalSupport()) { QDBusError error = xdgDesktopPortalSendEmail(url); - if (isPortalReturnPermanent(error)) - return !error.isValid(); + if (!error.isValid()) + return true; // service not running, fall back } @@ -324,8 +316,8 @@ bool QGenericUnixServices::openUrl(const QUrl &url) #if QT_CONFIG(dbus) if (checkNeedPortalSupport()) { QDBusError error = xdgDesktopPortalOpenUrl(url); - if (isPortalReturnPermanent(error)) - return !error.isValid(); + if (!error.isValid()) + return true; } #endif @@ -341,8 +333,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url) #if QT_CONFIG(dbus) if (checkNeedPortalSupport()) { QDBusError error = xdgDesktopPortalOpenFile(url); - if (isPortalReturnPermanent(error)) - return !error.isValid(); + if (!error.isValid()) + return true; } #endif |