Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ behavior they verify rather than listed separately.

### Fixed

- Require PyQt5-sip 12.20.1 or later to avoid native shutdown crashes when
Qt cleanup callbacks create or destroy wrapped objects.

- Clean up synthetic scene windows before the graphics diagnostic exits, including
failed probes, instead of leaving native Qt window destruction to interpreter shutdown.

Expand Down
35 changes: 34 additions & 1 deletion phy/gui/tests/test_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
# Imports
# ------------------------------------------------------------------------------

from pytest import raises
import subprocess
import sys
from textwrap import dedent

from pytest import mark, raises

from ..qt import (
AsyncCaller,
Expand Down Expand Up @@ -37,6 +41,35 @@
# ------------------------------------------------------------------------------


@mark.parametrize('count', [256, 1024, 4096])
def test_qt_exit_callbacks_can_replace_wrappers(count):
# PyQt's exit visitor must tolerate callbacks that delete/create wrappers.
# A subprocess is essential: the old SIP runtime crashes after Python tests
# have finished, so an in-process assertion cannot detect the regression.
code = dedent(f"""
from PyQt5.QtCore import QCoreApplication, QObject

app = QCoreApplication([])
retained = [QObject() for _ in range({count})]
trigger = QObject()

def rebuild(*args):
retained.clear()
retained.extend(QObject() for _ in range({count * 2}))
print('rebuilt', len(retained), flush=True)

trigger.destroyed.connect(rebuild)
""")
result = subprocess.run(
[sys.executable, '-X', 'faulthandler', '-c', code],
capture_output=True,
text=True,
timeout=30,
)
assert result.returncode == 0, (result.returncode, result.stdout, result.stderr)
assert result.stdout.strip() == f'rebuilt {count * 2}'


def test_require_qt_with_app(monkeypatch):
calls = []

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies = [
"pillow",
"pip",
"PyQt5>=5.15.11,<5.16",
"PyQt5-sip>=12.20.1,<13",
"pyopengl>=3.1.9",
"qtconsole",
"requests",
Expand Down
50 changes: 30 additions & 20 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading