test(xrayeye): keep the ellipse-ROI test items in a module-lifetime QGraphicsScene
Read the Docs Deploy Trigger / trigger-rtd-webhook (push) Successful in 3s
CI for csaxs_bec / test (push) Successful in 4m27s

Unparented pyqtgraph ROIs could be garbage-collected while the next ROI was being
built, which crashed PySide6 in CI with --random-order (segfault in
GraphicsObject.itemChange during garbage collection). Test logic unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TNtKEk4jAyjebMDQFwRHJQ
This commit was merged in pull request #336.
This commit is contained in:
Mirko HollerandClaude Opus 5.5 authored and holler committed 2026-10-20 15:34:37 +02:00
1 parent 8796953913
commit 7c6cda681c
1 file changed
+17
@@ -27,6 +27,22 @@ def _qapp():
return pg.mkQApp()
# All test ROIs go into one scene that lives for the whole module: Qt then owns the items, and the
# Python garbage collector cannot delete an unparented ROI while the next one is being built (that
# crashed PySide6 / pyqtgraph in CI with --random-order: "Fatal Python error: Segmentation fault" in
# GraphicsObject.itemChange during garbage collection).
_SCENE = None
@pytest.fixture(autouse=True, scope="module")
def _scene(_qapp):
global _SCENE
_SCENE = pg.QtWidgets.QGraphicsScene()
yield _SCENE
_SCENE.clear()
_SCENE = None
class _FakeEllipticalROI(pg.EllipseROI):
"""pg ellipse standing in for bec_widgets' EllipticalROI in isinstance checks."""
@@ -39,6 +55,7 @@ def _patch_roi_class():
def _roi(pos=(10.0, 20.0), size=(40.0, 20.0), angle=0.0):
roi = _FakeEllipticalROI(pos, size, angle=angle)
_SCENE.addItem(roi)
return roi