Skip to content

Commit a9f75cb

Browse files
committed
Restore local prefs only on initial config load
Add explicit type annotations for the settings stores and update `_apply_config` to accept a `restore_local_prefs` flag. The main window now restores persisted local preferences (like recording filename) only during initial startup, preventing later config applications from unintentionally overriding values loaded from the active config.
1 parent cf0293b commit a9f75cb

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎dlclivegui/gui/main_window.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def __init__(self, config: ApplicationSettings | None = None):
9797
self.setWindowTitle("DeepLabCut Live GUI")
9898

9999
self.settings = QSettings("DeepLabCut", "DLCLiveGUI")
100-
self._model_path_store = ModelPathStore(self.settings)
101-
self._settings_store = DLCLiveGUISettingsStore(self.settings)
100+
self._model_path_store: ModelPathStore = ModelPathStore(self.settings)
101+
self._settings_store: DLCLiveGUISettingsStore = DLCLiveGUISettingsStore(self.settings)
102102

103103
last_cfg_path = self._settings_store.get_last_config_path()
104104
last_cfg_file = self._valid_config_file_path(last_cfg_path)
@@ -198,7 +198,7 @@ def __init__(self, config: ApplicationSettings | None = None):
198198
self._preview_pixmap = QPixmap(LOGO_ALPHA)
199199
self._setup_ui()
200200
self._connect_signals()
201-
self._apply_config(self._config)
201+
self._apply_config(self._config, restore_local_prefs=True)
202202
self._refresh_processors() # Scan and populate processor dropdown
203203
self._update_inference_buttons()
204204
self._update_camera_controls_enabled()
@@ -874,7 +874,7 @@ def _connect_signals(self) -> None:
874874

875875
# ------------------------------------------------------------------
876876
# Config
877-
def _apply_config(self, config: ApplicationSettings) -> None:
877+
def _apply_config(self, config: ApplicationSettings, *, restore_local_prefs: bool = False) -> None:
878878
# Update active cameras label
879879
self._update_active_cameras_label()
880880

@@ -889,9 +889,10 @@ def _apply_config(self, config: ApplicationSettings) -> None:
889889
recording = config.recording
890890
self.output_directory_edit.setText(recording.directory)
891891
self.filename_edit.setText(recording.filename)
892-
persisted_filename = self._settings_store.get_rec_filename()
893-
if persisted_filename:
894-
self.filename_edit.setText(persisted_filename)
892+
if restore_local_prefs:
893+
persisted_filename = self._settings_store.get_rec_filename()
894+
if persisted_filename:
895+
self.filename_edit.setText(persisted_filename)
895896
self.container_combo.setCurrentText(recording.container)
896897
codec_index = self.codec_combo.findText(recording.codec)
897898
if codec_index >= 0:

0 commit comments

Comments
 (0)