From 62a81bddfa13b169e3e31174f22546afc3d211f1 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 29 Sep 2021 13:08:10 +0400 Subject: 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 Reviewed-by: Thiago Macieira --- src/gui/platform/unix/qgenericunixservices.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/gui/platform') 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 -- cgit v1.2.3