diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2020-07-06 00:29:49 +0200 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2020-07-06 01:18:53 +0200 |
commit | 55f19fffc08e369d3c49fa298048e0726bc3a854 (patch) | |
tree | 9c621c64f3fca9125ad22a3935af7b2059c17f57 /src | |
parent | 042d2ebf43184096fcac245cb847015e8025ee88 (diff) |
Make CO creator pointer management less thread-unsafe
Diffstat (limited to 'src')
-rw-r--r-- | src/control/control.h | 10 | ||||
-rw-r--r-- | src/control/controlobject.cpp | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/control/control.h b/src/control/control.h index 56df7d5ae2..b3dcb0ef1e 100644 --- a/src/control/control.h +++ b/src/control/control.h @@ -110,12 +110,12 @@ class ControlDoublePrivate : public QObject { return m_defaultValue.getValue(); } - inline ControlObject* getCreatorCO() const { - return m_pCreatorCO; + ControlObject* getCreatorCO() const { + return m_pCreatorCO.loadAcquire(); } - inline void removeCreatorCO() { - m_pCreatorCO = NULL; + bool resetCreatorCO(ControlObject* pCreatorCO) { + return m_pCreatorCO.testAndSetOrdered(pCreatorCO, nullptr); } inline ConfigKey getKey() { @@ -180,7 +180,7 @@ class ControlDoublePrivate : public QObject { QSharedPointer<ControlNumericBehavior> m_pBehavior; - ControlObject* m_pCreatorCO; + QAtomicPointer<ControlObject> m_pCreatorCO; // Hack to implement persistent controls. This is a pointer to the current // user configuration object (if one exists). In general, we do not want the diff --git a/src/control/controlobject.cpp b/src/control/controlobject.cpp index 2de1c38683..65d66a3647 100644 --- a/src/control/controlobject.cpp +++ b/src/control/controlobject.cpp @@ -54,7 +54,7 @@ ControlObject::ControlObject(ConfigKey key, bool bIgnoreNops, bool bTrack, ControlObject::~ControlObject() { if (m_pControl) { - m_pControl->removeCreatorCO(); + m_pControl->resetCreatorCO(this); } } |