mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Workaround for glibc > 2.33 breaking web engine
This commit is contained in:
parent
93961cb8ab
commit
f4b034f60e
@ -399,6 +399,26 @@ def is_widescreen():
|
|||||||
return _is_widescreen
|
return _is_widescreen
|
||||||
|
|
||||||
|
|
||||||
|
def disable_webengine_sandbox_if_needed():
|
||||||
|
# See https://sourceware.org/glibc/wiki/Glibc%20Timeline
|
||||||
|
if not isfrozen or iswindows or ismacos or QT_VERSION >= 0x60000:
|
||||||
|
return
|
||||||
|
import ctypes
|
||||||
|
libc = ctypes.CDLL(None)
|
||||||
|
try:
|
||||||
|
f = libc.gnu_get_libc_version
|
||||||
|
except AttributeError:
|
||||||
|
return
|
||||||
|
f.restype = ctypes.c_char_p
|
||||||
|
ver = f().decode('ascii')
|
||||||
|
q = tuple(map(int, ver.split('.')))
|
||||||
|
if q >= (2, 34):
|
||||||
|
setattr(disable_webengine_sandbox_if_needed, 'done', True)
|
||||||
|
setattr(disable_webengine_sandbox_if_needed, 'orig_val', os.environ.get('QTWEBENGINE_DISABLE_SANDBOX'))
|
||||||
|
print('Disabling Qt WebEngine sandbox as version of glibc on this system will break it', file=sys.stderr)
|
||||||
|
os.environ['QTWEBENGINE_DISABLE_SANDBOX'] = '1'
|
||||||
|
|
||||||
|
|
||||||
def extension(path):
|
def extension(path):
|
||||||
return os.path.splitext(path)[1][1:].lower()
|
return os.path.splitext(path)[1][1:].lower()
|
||||||
|
|
||||||
@ -925,6 +945,7 @@ class Application(QApplication):
|
|||||||
|
|
||||||
def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False, color_prefs=gprefs, windows_app_uid=None):
|
def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False, color_prefs=gprefs, windows_app_uid=None):
|
||||||
self.ignore_palette_changes = False
|
self.ignore_palette_changes = False
|
||||||
|
disable_webengine_sandbox_if_needed()
|
||||||
QNetworkProxyFactory.setUseSystemConfiguration(True)
|
QNetworkProxyFactory.setUseSystemConfiguration(True)
|
||||||
# Allow import of webengine after construction of QApplication on new
|
# Allow import of webengine after construction of QApplication on new
|
||||||
# enough PyQt
|
# enough PyQt
|
||||||
@ -1301,6 +1322,8 @@ def sanitize_env_vars():
|
|||||||
else:
|
else:
|
||||||
env_vars = {}
|
env_vars = {}
|
||||||
|
|
||||||
|
if getattr(disable_webengine_sandbox_if_needed, 'done', False):
|
||||||
|
env_vars['QTWEBENGINE_DISABLE_SANDBOX'] = None
|
||||||
originals = {x:os.environ.get(x, '') for x in env_vars}
|
originals = {x:os.environ.get(x, '') for x in env_vars}
|
||||||
changed = {x:False for x in env_vars}
|
changed = {x:False for x in env_vars}
|
||||||
for var, suffix in iteritems(env_vars):
|
for var, suffix in iteritems(env_vars):
|
||||||
@ -1313,6 +1336,8 @@ def sanitize_env_vars():
|
|||||||
del os.environ[var]
|
del os.environ[var]
|
||||||
changed[var] = True
|
changed[var] = True
|
||||||
|
|
||||||
|
if getattr(disable_webengine_sandbox_if_needed, 'orig_val', False):
|
||||||
|
os.environ['QTWEBENGINE_DISABLE_SANDBOX'] = disable_webengine_sandbox_if_needed.orig_val
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user