summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-06-12 06:10:28 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-06-12 06:10:28 +0200
commit041d34fe4eb2f3cde6bab9313c6c2f63e3db4776 (patch)
tree636935622e2b15a8d1195dd24522d013110a62cd /FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
parentf0790cee70bb95209f42ea54e2a96f17b02110d6 (diff)
fix a data race caused by std::atomic usage
There was a window between grabbing the atomically-stored pointer and unsetting it. The exchange method allows for doing this in a really atomic fashion, however. Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
Diffstat (limited to 'FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp')
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
index e3823291..869c15de 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
@@ -123,11 +123,10 @@ void Tracker::apply(settings& s)
void Tracker::apply_inner()
{
qDebug()<<"Tracker:: Applying settings";
- settings* tmp = new_settings;
+ settings* tmp = new_settings.exchange(nullptr);
if (tmp == nullptr)
return;
auto& s = *tmp;
- new_settings = nullptr;
camera.set_device_index(s.cam_index);
camera.set_res(s.cam_res_x, s.cam_res_y);
camera.set_fps(s.cam_fps);