diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-07-06 17:04:08 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-07-06 17:04:08 +0200 |
commit | 8b4061609304743e4082e02f8c91e5ba0fd3c2a3 (patch) | |
tree | 2e74fd6e9591ccd668a3311271acb95f3e7a634b | |
parent | f822e5e1217fd0a44e17e7a0d39e115095270cc0 (diff) |
Remove data race between UI and tracker thread
-rw-r--r-- | facetracknoir/tracker.cpp | 4 | ||||
-rw-r--r-- | facetracknoir/tracker.h | 1 |
2 files changed, 5 insertions, 0 deletions
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
|