Mercurial > hg > svcore
diff data/model/SparseModel.h @ 1212:f80773b5ec96 piper
More cautious locking on sparse model modification
author | Chris Cannam |
---|---|
date | Mon, 17 Oct 2016 14:28:43 +0100 |
parents | 815f82508f96 |
children | 771a17925576 |
line wrap: on
line diff
--- a/data/model/SparseModel.h Mon Oct 17 14:18:23 2016 +0100 +++ b/data/model/SparseModel.h Mon Oct 17 14:28:43 2016 +0100 @@ -729,8 +729,8 @@ { QMutexLocker locker(&m_mutex); m_resolution = resolution; + m_rows.clear(); } - m_rows.clear(); emit modelChanged(); } @@ -742,8 +742,8 @@ QMutexLocker locker(&m_mutex); m_points.clear(); m_pointCount = 0; + m_rows.clear(); } - m_rows.clear(); emit modelChanged(); } @@ -751,12 +751,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 @@ -783,18 +782,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; @@ -804,21 +801,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 @@ -831,6 +827,8 @@ { // std::cerr << "SparseModel::setCompletion(" << completion << ")" << std::endl; + QMutexLocker locker(&m_mutex); + if (m_completion != completion) { m_completion = completion;