@@ -196,14 +196,17 @@ def __init__(self, config: ApplicationSettings | None = None):
196196
197197 # Validate cameras from loaded config (deferred to allow window to show first)
198198 # NOTE IMPORTANT (tests/CI): This is scheduled via a QTimer and may fire during pytest-qt teardown.
199- QTimer .singleShot (100 , self ._validate_configured_cameras )
199+ # NOTE @C-Achard 2026-03-02: Handling this in closeEvent should help
200+ self ._camera_validation_timer = QTimer (self )
201+ self ._camera_validation_timer .setSingleShot (True )
202+ self ._camera_validation_timer .timeout .connect (self ._validate_configured_cameras )
203+ self ._camera_validation_timer .start (100 )
200204 # If validation triggers a modal QMessageBox (warning/error) while the parent window is closing,
201205 # it can cause errors with unpredictable timing (heap corruption / access violations).
202206 #
203207 # Mitigations for tests/CI:
204208 # - Disable this timer by monkeypatching _validate_configured_cameras in GUI tests
205209 # - OR monkeypatch/override _show_warning/_show_error to no-op in GUI tests (easiest)
206- # - OR use a cancellable QTimer attribute and stop() it in closeEvent
207210
208211 def resizeEvent (self , event ):
209212 super ().resizeEvent (event )
@@ -1396,7 +1399,7 @@ def _on_multi_frame_ready(self, frame_data: MultiFrameData) -> None:
13961399 dlc_cam_id = selected_id
13971400 else :
13981401 dlc_cam_id = available_ids [0 ] if available_ids else ""
1399- if dlc_cam_id is not None :
1402+ if dlc_cam_id :
14001403 self ._inference_camera_id = dlc_cam_id
14011404 self ._set_dlc_combo_to_id (dlc_cam_id )
14021405 self .statusBar ().showMessage (
@@ -2044,6 +2047,8 @@ def closeEvent(self, event: QCloseEvent) -> None: # pragma: no cover - GUI beha
20442047 if self .multi_camera_controller .is_running ():
20452048 self .multi_camera_controller .stop (wait = True )
20462049
2050+ if hasattr (self , "_camera_validation_timer" ) and self ._camera_validation_timer .isActive ():
2051+ self ._camera_validation_timer .stop ()
20472052 # Stop all multi-camera recorders
20482053 self ._rec_manager .stop_all ()
20492054
0 commit comments