diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2021-10-16 18:04:01 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2021-10-16 18:20:50 +0200 |
commit | 56cb66f9e63ab89ffcc77881aa44790950f62b57 (patch) | |
tree | 77a7c2c9936d1487edae8b3b9726f173ef4f1981 /tracker-pt/ftnoir_tracker_pt.cpp | |
parent | 16012cb1eb5ad7bb893bb3168fb3aec1608b8e56 (diff) |
tracker/pt: bail out early on camera open failure
Diffstat (limited to 'tracker-pt/ftnoir_tracker_pt.cpp')
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index 234b3137..4fc6f99a 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -42,7 +42,8 @@ Tracker_PT::~Tracker_PT() wait(); QMutexLocker l(&camera_mtx); - camera->stop(); + if (camera) + camera->stop(); } void Tracker_PT::run() @@ -53,13 +54,14 @@ void Tracker_PT::run() { if (reopen_camera_flag) { + QMutexLocker l(&camera_mtx); + reopen_camera_flag = false; if (camera) camera->stop(); camera = traits->make_camera(); set_fov(s.fov); { - QMutexLocker l(&camera_mtx); if (!camera->start(s)) break; } @@ -127,7 +129,12 @@ void Tracker_PT::set_fov(int value) module_status Tracker_PT::start_tracker(QFrame* video_frame) { - //video_frame->setAttribute(Qt::WA_NativeWindow); + { + QMutexLocker l(&camera_mtx); + auto camera = traits->make_camera(); + if (!camera || !camera->start(s)) + return error(tr("Failed to open camera '%1'").arg(s.camera_name)); + } widget = std::make_unique<video_widget>(video_frame); layout = std::make_unique<QHBoxLayout>(video_frame); |