Skip to content

Commit fbbefe7

Browse files
committed
Handle recording stop failures in UI
Emit a dedicated async signal when stopping a recording raises an exception, and handle it on the GUI thread. The new failure handler clears the stopping state, restores start/stop button availability based on recorder activity, updates camera controls, and shows a longer status-bar error message so users get clear feedback instead of a silent stuck state.
1 parent f2b034c commit fbbefe7

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎dlclivegui/gui/main_window.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class DLCLiveMainWindow(QMainWindow):
9595
"""Main application window."""
9696

9797
_recording_stopped_async = Signal()
98+
_rec_stop_failed_async = Signal(str)
9899

99100
def __init__(self, config: ApplicationSettings | None = None):
100101
super().__init__()
@@ -193,6 +194,7 @@ def __init__(self, config: ApplicationSettings | None = None):
193194
# Recording state
194195
self._recording_stopping = False
195196
self._recording_stopped_async.connect(self._on_recording_stopped_async)
197+
self._rec_stop_failed_async.connect(self._on_recording_stop_failed_async)
196198

197199
self._load_icons()
198200
self._preview_pixmap = QPixmap(LOGO_ALPHA)
@@ -1910,6 +1912,7 @@ def worker():
19101912
raise RuntimeError("Could not stop recording within timeout period.")
19111913
except Exception as e:
19121914
logger.exception("Error while stopping recording: %s", e)
1915+
self._rec_stop_failed_async.emit(str(e))
19131916
return
19141917

19151918
self._recording_stopped_async.emit()
@@ -2072,6 +2075,19 @@ def _on_recording_stopped_async(self) -> None:
20722075
self.statusBar().showMessage("Multi-camera recording stopped", 3000)
20732076
self._update_camera_controls_enabled()
20742077

2078+
def _on_recording_stop_failed_async(self, message: str) -> None:
2079+
self._recording_stopping = False
2080+
2081+
still_active = self._rec_manager.is_active
2082+
self.start_record_button.setEnabled(not still_active)
2083+
self.stop_record_button.setEnabled(still_active)
2084+
2085+
self.statusBar().showMessage(
2086+
f"Failed to stop recording: {message}",
2087+
10000,
2088+
)
2089+
self._update_camera_controls_enabled()
2090+
20752091
# ------------------------------------------------------------------
20762092
# Camera control
20772093
def _show_logo_and_text(self):

0 commit comments

Comments
 (0)