Skip to content

fix: prevent PySide6 6.11.0 segfault and CDockManager 4.5.x teardown crashes#1180

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/make-bec-widgets-compatible-with-pyside6-611
Draft

fix: prevent PySide6 6.11.0 segfault and CDockManager 4.5.x teardown crashes#1180
Copilot wants to merge 2 commits into
mainfrom
copilot/make-bec-widgets-compatible-with-pyside6-611

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

Description

Three targeted fixes for teardown crashes introduced by PySide6 6.11.0 and PySide6-QtAds 4.5.x. PySide6 6.11.0 segfaults when setParent() targets a widget mid-destruction; QtAds 4.5.x is stricter about dock widget teardown order.

Root cause (segfault): _destroyed was set after cleanup() returned, so during teardown the flag was False. This allowed _parking_parent to return console.window() (the enclosing DeveloperWidget) as a reparenting target — already being destroyed — causing setParent() to segfault.

DeveloperWidget.closeEvent → cleanup → delete_all → _delete_dock →
BecConsole.close → cleanup → registry.unregister → _park_terminal →
_parking_parent(avoid_console=True) → console.window() = DeveloperWidget
→ setParent(mid-destruction widget) → SEGFAULT

Fixes:

  • bec_widget.py — move self._destroyed = True to before self.cleanup() in closeEvent(), making the flag available throughout the entire teardown chain

  • bec_console.py — in _parking_parent(), skip console.window() as a parking target when window._destroyed is True, falling back to _fallback_holder instead

  • basic_dock_area.py — add DockAreaWidget.cleanup() that calls delete_all() before super().cleanup(), ensuring CDockWidgets are released through the Qt ADS API (closeDockWidget / deleteDockWidget) before BECWidget.cleanup() processes them as generic children; delete_all() is idempotent so subclasses that already call it in their own cleanup() are unaffected

Related Issues

Type of Change

  • Bug fix: prevent segfault in BecConsole._park_terminal with PySide6 6.11.0
  • Bug fix: prevent DeviceManagerDisplayWidget / DockAreaWidget teardown crash with PySide6-QtAds 4.5.x

How to test

  • Run unit tests
  • Close a DeveloperWidget (containing a BecConsole) — should not segfault
  • Close a DeviceManagerDisplayWidget — should not crash

Potential side effects

_destroyed = True is now set earlier in closeEvent. Any code that checked _destroyed to gate re-entrant calls during cleanup() will now correctly see True; this is the intended behavior. No other known side effects.

Screenshots / GIFs (if applicable)

N/A

Additional Comments

CI is pending maintainer approval to run on this bot-submitted PR. The prior CI run (pre-fix, SHA f4d51b62) showed exit code 139 (segfault) in test_developer_view; these fixes address that crash chain directly.

Definition of Done

  • Documentation is up-to-date.

Copilot AI changed the title feat: make BEC Widgets compatible with PySide6 6.11 feat: bump PySide6 to 6.11.0 and PySide6-QtAds to 4.5.0.4 May 29, 2026
Copilot AI requested a review from wyzula-jan May 29, 2026 12:20
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark comparison

Threshold: 20% (lower is better).
Result: 0 regression(s), 1 improvement(s) beyond threshold.

No benchmark regression exceeded the configured threshold.

1 benchmark(s) improved beyond the configured threshold.

Benchmark Baseline Current Change
BEC IPython client without companion app 2.21378 s 1.71133 s -22.70%
All benchmark results
Benchmark Baseline Current Change Status
BEC IPython client with companion app 5.91908 s 5.63855 s -4.74% ok
BEC IPython client without companion app 2.21378 s 1.71133 s -22.70% 🟢 improved
Import bec_widgets 0.0143291 s 0.011679 s -18.50% ok
tests/unit_tests/benchmarks/test_dock_area_benchmark.py::test_add_waveform_to_dock_area 0.151597 s 0.139595 s -7.92% ok

…6.11.0

- bec_widget.py: set _destroyed=True BEFORE calling cleanup() so the flag
  is available throughout the entire teardown phase
- bec_console.py: in _parking_parent, skip console.window() as parking
  target when the window is marked as _destroyed, preventing setParent()
  into a widget mid-destruction (segfault in PySide6 6.11.0)
- basic_dock_area.py: add DockAreaWidget.cleanup() that calls delete_all()
  first to release CDockWidgets via the Qt ADS API before BECWidget.cleanup()
  runs, fixing teardown crashes with PySide6-QtAds 4.5.x
Copilot AI changed the title feat: bump PySide6 to 6.11.0 and PySide6-QtAds to 4.5.0.4 fix: prevent PySide6 6.11.0 segfault and CDockManager 4.5.x teardown crashes May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants