From 041d34fe4eb2f3cde6bab9313c6c2f63e3db4776 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 12 Jun 2014 06:10:28 +0200 Subject: 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 --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'FTNoIR_Tracker_PT') 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); -- cgit v1.2.3