Mercurial > hg > svgui
diff layer/Colour3DPlotLayer.cpp @ 1473:886c1cd48f9d by-id
Further layer updates for ModelById
author | Chris Cannam |
---|---|
date | Tue, 02 Jul 2019 11:49:52 +0100 |
parents | f2525e6cbdf1 |
children | e540aa5d89cd |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Mon Jul 01 14:25:53 2019 +0100 +++ b/layer/Colour3DPlotLayer.cpp Tue Jul 02 11:49:52 2019 +0100 @@ -183,8 +183,10 @@ invalidateRenderers(); invalidateMagnitudes(); - delete m_peakCache; - m_peakCache = nullptr; + if (!m_peakCache.isNone()) { + ModelById::release(m_peakCache); + m_peakCache = {}; + } } void @@ -206,11 +208,14 @@ m_viewMags.clear(); } -Dense3DModelPeakCache * +ModelId Colour3DPlotLayer::getPeakCache() const { - if (!m_peakCache) { - m_peakCache = new Dense3DModelPeakCache(m_model, m_peakCacheDivisor); + if (m_peakCache.isNone()) { + auto peakCache = std::make_shared<Dense3DModelPeakCache> + (m_model, m_peakCacheDivisor); + ModelById::add(peakCache); + m_peakCache = peakCache->getId(); } return m_peakCache; }