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 | |
parent | 16012cb1eb5ad7bb893bb3168fb3aec1608b8e56 (diff) |
tracker/pt: bail out early on camera open failure
Diffstat (limited to 'tracker-pt')
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.cpp | 13 | ||||
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.h | 3 | ||||
-rw-r--r-- | tracker-pt/lang/nl_NL.ts | 7 | ||||
-rw-r--r-- | tracker-pt/lang/ru_RU.ts | 7 | ||||
-rw-r--r-- | tracker-pt/lang/stub.ts | 7 | ||||
-rw-r--r-- | tracker-pt/lang/zh_CN.ts | 7 |
6 files changed, 39 insertions, 5 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); diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index 50e51405..dd46f098 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -49,12 +49,11 @@ struct Tracker_PT : QThread, ITracker private: void run() override; - void set_fov(int value); pointer<pt_runtime_traits> traits; - QMutex camera_mtx; + mutable QRecursiveMutex camera_mtx; PointTracker point_tracker; diff --git a/tracker-pt/lang/nl_NL.ts b/tracker-pt/lang/nl_NL.ts index 99efccda..c61f7437 100644 --- a/tracker-pt/lang/nl_NL.ts +++ b/tracker-pt/lang/nl_NL.ts @@ -341,6 +341,13 @@ Don't roll or change position.</source> </message> </context> <context> + <name>pt_impl::Tracker_PT</name> + <message> + <source>Failed to open camera '%1'</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>pt_module::metadata_pt</name> <message> <source>PointTracker 1.1</source> diff --git a/tracker-pt/lang/ru_RU.ts b/tracker-pt/lang/ru_RU.ts index 3b288720..027aed6f 100644 --- a/tracker-pt/lang/ru_RU.ts +++ b/tracker-pt/lang/ru_RU.ts @@ -346,6 +346,13 @@ ROLL или X/Y-смещения.</translation> </message> </context> <context> + <name>pt_impl::Tracker_PT</name> + <message> + <source>Failed to open camera '%1'</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>pt_module::metadata_pt</name> <message> <source>PointTracker 1.1</source> diff --git a/tracker-pt/lang/stub.ts b/tracker-pt/lang/stub.ts index 77823135..072128be 100644 --- a/tracker-pt/lang/stub.ts +++ b/tracker-pt/lang/stub.ts @@ -341,6 +341,13 @@ Don't roll or change position.</source> </message> </context> <context> + <name>pt_impl::Tracker_PT</name> + <message> + <source>Failed to open camera '%1'</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>pt_module::metadata_pt</name> <message> <source>PointTracker 1.1</source> diff --git a/tracker-pt/lang/zh_CN.ts b/tracker-pt/lang/zh_CN.ts index 99ab5ea1..d3dccad5 100644 --- a/tracker-pt/lang/zh_CN.ts +++ b/tracker-pt/lang/zh_CN.ts @@ -341,6 +341,13 @@ Don't roll or change position.</source> </message> </context> <context> + <name>pt_impl::Tracker_PT</name> + <message> + <source>Failed to open camera '%1'</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>pt_module::metadata_pt</name> <message> <source>PointTracker 1.1</source> |