Mercurial > hg > svcore
diff data/model/ImageModel.h @ 1798:13bd41bd8a17
Some work on making Model classes thread-safe in typical use - and documenting this. Some of the implementations are simpler now that EventSeries is thread-safe
author | Chris Cannam |
---|---|
date | Tue, 01 Oct 2019 11:22:48 +0100 |
parents | 6d09d68165a4 |
children | 343ef2a866a4 |
line wrap: on
line diff
--- a/data/model/ImageModel.h Tue Oct 01 11:21:56 2019 +0100 +++ b/data/model/ImageModel.h Tue Oct 01 11:22:48 2019 +0100 @@ -76,10 +76,8 @@ void setCompletion(int completion, bool update = true) { - { QMutexLocker locker(&m_mutex); - if (m_completion == completion) return; - m_completion = completion; - } + if (m_completion == completion) return; + m_completion = completion; if (update) { m_notifier.makeDeferredNotifications(); @@ -141,18 +139,12 @@ * Editing methods. */ void add(Event e) override { - - { QMutexLocker locker(&m_mutex); - m_events.add(e.withoutDuration().withoutValue().withoutLevel()); - } - + m_events.add(e.withoutDuration().withoutValue().withoutLevel()); m_notifier.update(e.getFrame(), m_resolution); } void remove(Event e) override { - { QMutexLocker locker(&m_mutex); - m_events.remove(e); - } + m_events.remove(e); emit modelChangedWithin(getId(), e.getFrame(), e.getFrame() + m_resolution); } @@ -281,11 +273,9 @@ int m_resolution; DeferredNotifier m_notifier; - int m_completion; + std::atomic<int> m_completion; EventSeries m_events; - - mutable QMutex m_mutex; };