mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Linux: Fix external applications not being launched under Wayland
This commit is contained in:
parent
93e6761a63
commit
23bbc95f96
@ -1462,7 +1462,13 @@ def open_url(qurl):
|
|||||||
# Qt 5 requires QApplication to be constructed before trying to use
|
# Qt 5 requires QApplication to be constructed before trying to use
|
||||||
# QDesktopServices::openUrl()
|
# QDesktopServices::openUrl()
|
||||||
ensure_app()
|
ensure_app()
|
||||||
ok = QDesktopServices.openUrl(qurl)
|
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:
|
if not ok:
|
||||||
# this happens a lot with Qt 6.5.3. On Wayland, Qt requires
|
# this happens a lot with Qt 6.5.3. On Wayland, Qt requires
|
||||||
# BOTH a QApplication AND a top level window so it can use the
|
# BOTH a QApplication AND a top level window so it can use the
|
||||||
@ -1470,7 +1476,6 @@ def open_url(qurl):
|
|||||||
print('QDesktopServices::openUrl() failed for url:', qurl, file=sys.stderr)
|
print('QDesktopServices::openUrl() failed for url:', qurl, file=sys.stderr)
|
||||||
if islinux:
|
if islinux:
|
||||||
import subprocess
|
import subprocess
|
||||||
cmd = ['xdg-open', qurl.toLocalFile() if qurl.isLocalFile() else qurl.toString(QUrl.ComponentFormattingOption.FullyEncoded)]
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print('Running opener:', cmd)
|
print('Running opener:', cmd)
|
||||||
subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user