diff options
Diffstat (limited to 'qfunctionconfigurator/functionconfig.cpp')
-rw-r--r-- | qfunctionconfigurator/functionconfig.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 6e1569f9..f9c9957e 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -21,9 +21,9 @@ // // Constructor with List of Points in argument. // -FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) +FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) : + _mutex(QMutex::Recursive) { - _mutex = new QMutex(QMutex::Recursive); _title = title; _points = QList<QPointF>(); _data = 0; @@ -45,14 +45,13 @@ void FunctionConfig::setTrackingActive(bool blnActive) } FunctionConfig::FunctionConfig() : + _mutex(QMutex::Recursive), + _data(0), + _size(0), _tracking_active(false), _max_Input(0), - _max_Output(0), - _data(0), - _mutex(0), - _size(0) + _max_Output(0) { - _mutex = new QMutex(); } // @@ -61,7 +60,7 @@ FunctionConfig::FunctionConfig() : // The return-value is also stored internally, so the Widget can show the current value, when the Tracker is running. // float FunctionConfig::getValue(float x) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); int x2 = (int) (std::min<float>(std::max<float>(x, -360), 360) * MEMOIZE_PRECISION); float ret = getValueInternal(x2); lastValueTracked.setX(x); @@ -73,7 +72,7 @@ float FunctionConfig::getValue(float x) { // The return-value is also stored internally, so the Widget can show the current value, when the Tracker is running. // bool FunctionConfig::getLastPoint(QPointF& point ) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); point = lastValueTracked; return _tracking_active; } @@ -172,8 +171,6 @@ void FunctionConfig::reload() { FunctionConfig::~FunctionConfig() { if (_data) delete[] _data; - if (_mutex) - delete _mutex; } // @@ -181,7 +178,7 @@ FunctionConfig::~FunctionConfig() { // Used by the Widget. // void FunctionConfig::removePoint(int i) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); if (i >= 0 && i < _points.size()) { _points.removeAt(i); @@ -194,7 +191,7 @@ void FunctionConfig::removePoint(int i) { // Used by the Widget and by loadSettings. // void FunctionConfig::addPoint(QPointF pt) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); _points.append(pt); reload(); } @@ -204,7 +201,7 @@ void FunctionConfig::addPoint(QPointF pt) { // Used by the Widget. // void FunctionConfig::movePoint(int idx, QPointF pt) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); if (idx >= 0 && idx < _points.size()) { _points[idx] = pt; @@ -218,8 +215,8 @@ void FunctionConfig::movePoint(int idx, QPointF pt) { // QList<QPointF> FunctionConfig::getPoints() { QList<QPointF> ret; - QMutexLocker foo(_mutex); - for (int i = 0; i < _points.size(); i++) { + QMutexLocker foo(&_mutex); + for (int i = 0; i < _points.size(); i++) { ret.append(_points[i]); } return ret; @@ -230,7 +227,7 @@ QList<QPointF> FunctionConfig::getPoints() { // Settings for a specific Curve are loaded from their own Group in the INI-file. // void FunctionConfig::loadSettings(QSettings& settings) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); QPointF newPoint; QList<QPointF> points; @@ -266,7 +263,7 @@ void FunctionConfig::loadSettings(QSettings& settings) { // The number of Points is also saved, to make loading more convenient. // void FunctionConfig::saveSettings(QSettings& settings) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); settings.beginGroup(QString("Curves-%1").arg(_title)); int max = _points.size(); settings.setValue("point-count", max); |