@@ -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 )
@@ -1373,7 +1376,7 @@ def _on_multi_frame_ready(self, frame_data: MultiFrameData) -> None:
13731376 dlc_cam_id = selected_id
13741377 else :
13751378 dlc_cam_id = available_ids [0 ] if available_ids else ""
1376- if dlc_cam_id is not None :
1379+ if dlc_cam_id :
13771380 self ._inference_camera_id = dlc_cam_id
13781381 self ._set_dlc_combo_to_id (dlc_cam_id )
13791382 self .statusBar ().showMessage (
@@ -2021,6 +2024,8 @@ def closeEvent(self, event: QCloseEvent) -> None: # pragma: no cover - GUI beha
20212024 if self .multi_camera_controller .is_running ():
20222025 self .multi_camera_controller .stop (wait = True )
20232026
2027+ if hasattr (self , "_camera_validation_timer" ) and self ._camera_validation_timer .isActive ():
2028+ self ._camera_validation_timer .stop ()
20242029 # Stop all multi-camera recorders
20252030 self ._rec_manager .stop_all ()
20262031
0 commit comments