Skip to content

Destroy the widgets of each test before the next one - #406

Merged
PierreRaybaut merged 1 commit into
developfrom
fix/release-closed-main-window
Oct 20, 2026
Merged

PierreRaybaut merged 1 commit into
developfrom
fix/release-closed-main-window

Conversation

@PierreRaybaut

Copy link
Copy Markdown
Contributor

Main windows created by tests were destroyed at an arbitrary point of the next test, possibly amid Qt operations. This is a plausible cause of the intermittent segmentation fault seen on develop after #402 (in side_by_side_app_test.py, right when the previous main window became garbage), although it is not proven: see #405 for the diagnostics.

What kept a closed main window alive

Reference Released
SigimaX singleton instance (SGMXMainWindow.get_instance) when the next main window was created
Web API controller (datalab.webapi), shared by all main windows when the next main window was created
Closed internal console (WA_DeleteOnClose), whose namespace references the main window by the next event loop, i.e. during the next test

The main window being part of reference cycles, it was then only destroyed when the garbage collector happened to run.

Changes

  • Web API: when its main window is closed, WebApiActions.cleanup disconnects its actions from the shared controller (they could otherwise be notified by a server started from another window) and the controller releases the window (release_main_window). Stopping the server also releases the workspace adapter set for the routes, which references the main window.
  • Tests (conftest.py): after each test, pending events and deferred deletions are processed, then the garbage collector is run.
  • Requires Release the closed main window as singleton instance SigimaX#11 (same branch name, used by CI): a main window closed for good is no longer kept as singleton instance.

Validation

  • With all changes, no main window of a test is alive at the start of the next one (it was before, even after gc.collect()).
  • Full test suite passes locally (1028 passed, 3 skipped). Running deferred deletions and the garbage collector after each test adds about 7% to the duration (290 s → 310 s on features/image).

A closed main window stayed alive until the next test created its own: it was
referenced by the Web API controller, shared by all main windows, and by the
SigimaX singleton instance, while the closed internal console, deleted later
by Qt, was only deleted by the next event loop. The previous main window was
then destroyed by the garbage collector at an arbitrary point of the next
test, possibly amid Qt operations.

- Web API: when its main window is closed, the controller no longer
  references it (nor its actions, which no longer receive server
  notifications), and stopping the server releases the workspace adapter
- Tests: pending events and deferred deletions are processed after each
  test, then the garbage collector is run

Requires the SigimaX fix releasing the closed main window as singleton
instance (same branch name).

Assisted-by: Claude Opus 5.5
@PierreRaybaut
PierreRaybaut merged commit 1cb8ff0 into develop Oct 20, 2026
6 checks passed
@PierreRaybaut
PierreRaybaut deleted the fix/release-closed-main-window branch October 23, 2026 14:38
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.

1 participant