Work around PyQt 5.6 segfault when using IPC
PyQt 5.6 seems to segfault when emitting None with a signal which is declared as emitting a string: https://www.riverbankcomputing.com/pipermail/pyqt/2016-April/037375.html We now avoid this by using an empty string explicitly instead of None.
This commit is contained in:
parent
48b069e89c
commit
3c8598f691
@ -244,12 +244,7 @@ def process_pos_args(args, via_ipc=False, cwd=None, target_arg=None):
|
||||
cwd: The cwd to use for fuzzy_url.
|
||||
target_arg: Command line argument received by a running instance via
|
||||
ipc. If the --target argument was not specified, target_arg
|
||||
will be an empty string instead of None. This behavior is
|
||||
caused by the PyQt signal
|
||||
``got_args = pyqtSignal(list, str, str)``
|
||||
used in the misc.ipc.IPCServer class. PyQt converts the
|
||||
None value into a null QString and then back to an empty
|
||||
python string
|
||||
will be an empty string.
|
||||
"""
|
||||
if via_ipc and not args:
|
||||
win_id = mainwindow.get_window(via_ipc, force_window=True)
|
||||
@ -275,6 +270,8 @@ def process_pos_args(args, via_ipc=False, cwd=None, target_arg=None):
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=win_id)
|
||||
log.init.debug("Startup URL {}".format(cmd))
|
||||
if not cwd: # could also be an empty string due to the PyQt signal
|
||||
cwd = None
|
||||
try:
|
||||
url = urlutils.fuzzy_url(cmd, cwd, relative=True)
|
||||
except urlutils.InvalidUrlError as e:
|
||||
|
@ -340,8 +340,17 @@ class IPCServer(QObject):
|
||||
self._handle_invalid_data()
|
||||
return
|
||||
|
||||
cwd = json_data.get('cwd', None)
|
||||
self.got_args.emit(json_data['args'], json_data['target_arg'], cwd)
|
||||
args = json_data['args']
|
||||
|
||||
target_arg = json_data['target_arg']
|
||||
if target_arg is None:
|
||||
# https://www.riverbankcomputing.com/pipermail/pyqt/2016-April/037375.html
|
||||
target_arg = ''
|
||||
|
||||
cwd = json_data.get('cwd', '')
|
||||
assert cwd is not None
|
||||
|
||||
self.got_args.emit(args, target_arg, cwd)
|
||||
self._timer.start()
|
||||
|
||||
@pyqtSlot()
|
||||
|
Loading…
Reference in New Issue
Block a user