Skip to content

Commit 25fe779

Browse files
committed
Update CameraProbeWorker.run()
The run() method just emitted success with the camera settings and the actual camera open/close ran on the GUI thread, blocking the UI. this is now changed to: - `CameraProbeWorker.run()` — now does the actual camera open/read/close on the background thread and emits a plain dict with the results. - `_on_probe_success()` — unpacks actual_res/actual_fps from the received dict instead of doing I/O. Everything else (model updates, UI refreshes) stays identical.
1 parent 6e8d653 commit 25fe779

1 file changed

Lines changed: 26 additions & 15 deletions

File tree

dlclivegui/gui/camera_config_dialog.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,25 @@ def run(self):
134134
self.progress.emit("Probing device defaults…")
135135
if self._cancel:
136136
return
137-
self.success.emit(self._cam)
137+
be = CameraFactory.create(self._cam)
138+
be.open()
139+
140+
actual_res = getattr(be, "actual_resolution", None)
141+
actual_fps = getattr(be, "actual_fps", None)
142+
143+
try:
144+
be.close()
145+
except Exception:
146+
pass
147+
148+
if self._cancel:
149+
return
150+
151+
self.success.emit({
152+
"cam": self._cam,
153+
"actual_resolution": actual_res,
154+
"actual_fps": actual_fps,
155+
})
138156
except Exception as exc:
139157
self.error.emit(f"{type(exc).__name__}: {exc}")
140158
finally:
@@ -1221,27 +1239,20 @@ def _reset_selected_camera(self, *, clear_backend_cache: bool = False) -> None:
12211239
self.apply_settings_btn.setEnabled(True)
12221240

12231241
def _on_probe_success(self, payload) -> None:
1224-
"""Open/close quickly to read actual_resolution/actual_fps and store as detected_*.
1242+
"""Apply probe results to working model and refresh UI.
12251243
12261244
If self._probe_apply_to_requested is True, also overwrite requested width/height/fps
12271245
for the targeted camera row (Reset behavior).
12281246
"""
1229-
if not isinstance(payload, CameraSettings):
1247+
if not isinstance(payload, dict):
1248+
return
1249+
cam_settings = payload.get("cam")
1250+
if not isinstance(cam_settings, CameraSettings):
12301251
return
1231-
cam_settings = payload
1252+
actual_res = payload.get("actual_resolution")
1253+
actual_fps = payload.get("actual_fps")
12321254

12331255
try:
1234-
be = CameraFactory.create(cam_settings)
1235-
be.open()
1236-
1237-
actual_res = getattr(be, "actual_resolution", None)
1238-
actual_fps = getattr(be, "actual_fps", None)
1239-
1240-
try:
1241-
be.close()
1242-
except Exception:
1243-
pass
1244-
12451256
backend = (cam_settings.backend or "").lower()
12461257

12471258
for i, c in enumerate(self._working_settings.cameras):

0 commit comments

Comments
 (0)