Mercurial > hg > svcore
diff data/model/SparseModel.h @ 1239:5261a7791f1c 3.0-integration
Merge from branch piper
author | Chris Cannam |
---|---|
date | Fri, 28 Oct 2016 15:20:58 +0100 |
parents | 771a17925576 |
children | cbdd534f517a |
line wrap: on
line diff
--- a/data/model/SparseModel.h Thu Oct 20 11:16:22 2016 +0100 +++ b/data/model/SparseModel.h Fri Oct 28 15:20:58 2016 +0100 @@ -730,8 +730,8 @@ { QMutexLocker locker(&m_mutex); m_resolution = resolution; + m_rows.clear(); } - m_rows.clear(); emit modelChanged(); } @@ -743,8 +743,8 @@ QMutexLocker locker(&m_mutex); m_points.clear(); m_pointCount = 0; + m_rows.clear(); } - m_rows.clear(); emit modelChanged(); } @@ -752,12 +752,11 @@ void SparseModel<PointType>::addPoint(const PointType &point) { - { - QMutexLocker locker(&m_mutex); - m_points.insert(point); - m_pointCount++; - if (point.getLabel() != "") m_hasTextLabels = true; - } + QMutexLocker locker(&m_mutex); + + m_points.insert(point); + m_pointCount++; + if (point.getLabel() != "") m_hasTextLabels = true; // Even though this model is nominally sparse, there may still be // too many signals going on here (especially as they'll probably @@ -784,18 +783,16 @@ bool SparseModel<PointType>::containsPoint(const PointType &point) { - { - QMutexLocker locker(&m_mutex); + QMutexLocker locker(&m_mutex); - PointListIterator i = m_points.lower_bound(point); - typename PointType::Comparator comparator; - while (i != m_points.end()) { - if (i->frame > point.frame) break; - if (!comparator(*i, point) && !comparator(point, *i)) { - return true; - } - ++i; - } + PointListIterator i = m_points.lower_bound(point); + typename PointType::Comparator comparator; + while (i != m_points.end()) { + if (i->frame > point.frame) break; + if (!comparator(*i, point) && !comparator(point, *i)) { + return true; + } + ++i; } return false; @@ -805,21 +802,20 @@ void SparseModel<PointType>::deletePoint(const PointType &point) { - { - QMutexLocker locker(&m_mutex); + QMutexLocker locker(&m_mutex); - PointListIterator i = m_points.lower_bound(point); - typename PointType::Comparator comparator; - while (i != m_points.end()) { - if (i->frame > point.frame) break; - if (!comparator(*i, point) && !comparator(point, *i)) { - m_points.erase(i); - m_pointCount--; - break; + PointListIterator i = m_points.lower_bound(point); + typename PointType::Comparator comparator; + while (i != m_points.end()) { + if (i->frame > point.frame) break; + if (!comparator(*i, point) && !comparator(point, *i)) { + m_points.erase(i); + m_pointCount--; + break; } - ++i; - } + ++i; } + // std::cout << "SparseOneDimensionalModel: emit modelChanged(" // << point.frame << ")" << std::endl; m_rows.clear(); //!!! inefficient @@ -832,6 +828,8 @@ { // std::cerr << "SparseModel::setCompletion(" << completion << ")" << std::endl; + QMutexLocker locker(&m_mutex); + if (m_completion != completion) { m_completion = completion;