Skip to content

Commit 43bec31

Browse files
committed
Prevent SEGFAULT when runtests.py exits
Disconnect all signal-slots connections of the main QThread just before runtests.py exits. This prevents a SEGFAULT when the finished signal of the main QThread is triggered. This is an issue in the PyQt6 bindings (PySide6 is also affected).
1 parent 50122eb commit 43bec31

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: runtests.py

+11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# Don't remove it or change it to a different location!
2222
# pylint: disable=wrong-import-position
2323
from qtpy import QtWebEngineWidgets # noqa
24+
25+
from qtpy.QtCore import QThread
2426
import pytest
2527

2628

@@ -59,6 +61,15 @@ def run_pytest(run_slow=False, extra_args=None, remoteclient=False):
5961
print("Pytest Arguments: " + str(pytest_args))
6062
errno = pytest.main(pytest_args)
6163

64+
# Disconnect all signal-slots connection of the main QThread just before
65+
# runtests.py exits. This prevents a SEGFAULT when the finished signal of
66+
# the main QThread is triggered. This is an issue in the PyQt6 bindings
67+
# (PySide6 is also affected).
68+
try:
69+
QThread.currentThread().disconnect()
70+
except TypeError: # raised when no signals are connected
71+
pass
72+
6273
# sys.exit doesn't work here because some things could be running in the
6374
# background (e.g. closing the main window) when this point is reached.
6475
# If that's the case, sys.exit doesn't stop the script as you would expect.

0 commit comments

Comments
 (0)