From 8b4061609304743e4082e02f8c91e5ba0fd3c2a3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 6 Jul 2013 17:04:08 +0200 Subject: Remove data race between UI and tracker thread --- facetracknoir/tracker.cpp | 4 ++++ facetracknoir/tracker.h | 1 + 2 files changed, 5 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index e34bf25e..93b09792 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -119,6 +119,8 @@ void Tracker::run() { { if (should_quit) break; + + QMutexLocker foo(&mtx); for (int i = 0; i < 6; i++) newpose[i] = 0; @@ -214,6 +216,7 @@ void Tracker::run() { // Get the raw headpose, so it can be displayed. // void Tracker::getHeadPose( double *data ) { + QMutexLocker foo(&mtx); for (int i = 0; i < 6; i++) { data[i] = mainApp->axis(i).headPos; @@ -224,6 +227,7 @@ void Tracker::getHeadPose( double *data ) { // Get the output-headpose, so it can be displayed. // void Tracker::getOutputHeadPose( double *data ) { + QMutexLocker foo(&mtx); for (int i = 0; i < 6; i++) data[i] = output_camera.axes[i]; } diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index de894cf5..f452395d 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -109,6 +109,7 @@ class Tracker : public QThread { private: FaceTrackNoIR *mainApp; + QMutex mtx; protected: // qthread override run method -- cgit v1.2.3