Linux: Fix external applications not being launched under Wayland

This commit is contained in:
Kovid Goyal 2023-11-25 13:01:51 +05:30
parent 93e6761a63
commit 23bbc95f96
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1462,6 +1462,12 @@ def open_url(qurl):
# Qt 5 requires QApplication to be constructed before trying to use
# QDesktopServices::openUrl()
ensure_app()
cmd = ['xdg-open', qurl.toLocalFile() if qurl.isLocalFile() else qurl.toString(QUrl.ComponentFormattingOption.FullyEncoded)]
if isfrozen and QApplication.instance().platformName() == "wayland":
# See https://bugreports.qt.io/browse/QTBUG-119438
subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
ok = True
else:
ok = QDesktopServices.openUrl(qurl)
if not ok:
# this happens a lot with Qt 6.5.3. On Wayland, Qt requires
@ -1470,7 +1476,6 @@ def open_url(qurl):
print('QDesktopServices::openUrl() failed for url:', qurl, file=sys.stderr)
if islinux:
import subprocess
cmd = ['xdg-open', qurl.toLocalFile() if qurl.isLocalFile() else qurl.toString(QUrl.ComponentFormattingOption.FullyEncoded)]
if DEBUG:
print('Running opener:', cmd)
subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)