From d1698206a697130a0729a429f07f7c19733cddca Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 18 Aug 2012 15:08:24 +0100 Subject: [PATCH] XYController: Fix cursor stuck when sending too many data --- c++/jack_utils.h | 2 +- c++/widgets/pixmapdial.h | 18 ++++++++++-------- c++/xycontroller/xycontroller.cpp | 15 +++++++++------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/c++/jack_utils.h b/c++/jack_utils.h index 557f832..face475 100644 --- a/c++/jack_utils.h +++ b/c++/jack_utils.h @@ -23,7 +23,7 @@ #include #ifdef HAVE_JACKSESSION -#include +# include #endif #include diff --git a/c++/widgets/pixmapdial.h b/c++/widgets/pixmapdial.h index 3eb6f64..c4e0610 100644 --- a/c++/widgets/pixmapdial.h +++ b/c++/widgets/pixmapdial.h @@ -24,11 +24,6 @@ class PixmapDial : public QDial { public: - enum Orientation { - HORIZONTAL = 0, - VERTICAL = 1 - }; - enum CustomPaint { CUSTOM_PAINT_NULL = 0, CUSTOM_PAINT_CARLA_WET = 1, @@ -57,6 +52,16 @@ protected: void resizeEvent(QResizeEvent* event); private: + enum Orientation { + HORIZONTAL = 0, + VERTICAL = 1 + }; + + static const unsigned short HOVER_MIN = 0; + static const unsigned short HOVER_MAX = 9; + + // ------------------------------------- + QPixmap m_pixmap; QString m_pixmap_n_str; @@ -79,9 +84,6 @@ private: QColor m_colorT[2]; int p_width, p_height, p_size, p_count; - - static const unsigned short HOVER_MIN = 0; - static const unsigned short HOVER_MAX = 9; }; #endif // PIXMAPDIAL_H diff --git a/c++/xycontroller/xycontroller.cpp b/c++/xycontroller/xycontroller.cpp index e6c261f..3e029fd 100644 --- a/c++/xycontroller/xycontroller.cpp +++ b/c++/xycontroller/xycontroller.cpp @@ -56,24 +56,27 @@ public: void copyDataFrom(Queue* queue) { - mutex.lock(); + // lock mutexes queue->mutex.lock(); + mutex.lock(); // copy data from queue memcpy(data, queue->data, sizeof(datatype)*MAX_SIZE); + index = queue->index; empty = queue->empty; full = queue->full; + // unlock our mutex, no longer needed + mutex.unlock(); + // reset queque memset(queue->data, 0, sizeof(datatype)*MAX_SIZE); + queue->index = 0; queue->empty = true; queue->full = false; - // reset indexes - index = queue->index = 0; - + // unlock queque mutex queue->mutex.unlock(); - mutex.unlock(); } bool isEmpty() @@ -133,7 +136,7 @@ public: if (lock) mutex.lock(); - full = false; + full = false; if (data[index].d1 == 0) {