aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-08-15 21:43:16 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-08-17 08:15:34 +0200
commit412be2096cea12ca480cbbd419f3531a41dac3ae (patch)
tree0c031390ea6c668a648559d2e07b77b0615cff51 /src/quick/scenegraph
parentefe0bec9468d75b768d1e26d2a8b440ade5ba632 (diff)
QSGDepthStencilBufferManager: don't use toStrongRef().data()
It's an anti-pattern. Even though we don't expect other threads to destroy the last QSP while we use the pointer obtained from QWeakPointer, play it safe and use QWeakPointer idiomatically: as a non-owning reference, to be converted to an owning one for the duration of our use of the payload object. Add an assertion that explains why we don't expect expired weak_ptrs here. Amends 0f035c0ad79ca41a1473b64a4c0077e7085d3700. Change-Id: Ia39ef5fa243e0e73110aae13da35f4f2ada73a73 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp
index a850f72053..1154c06d7c 100644
--- a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp
+++ b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp
@@ -183,7 +183,9 @@ void QSGDefaultDepthStencilBuffer::free()
QSGDepthStencilBufferManager::~QSGDepthStencilBufferManager()
{
for (Hash::const_iterator it = m_buffers.constBegin(), cend = m_buffers.constEnd(); it != cend; ++it) {
- QSGDepthStencilBuffer *buffer = it.value().toStrongRef().data();
+ QSharedPointer<QSGDepthStencilBuffer> buffer = it.value().toStrongRef();
+ Q_ASSERT_X(buffer, "~QSGDepthStencilBufferManager",
+ "~QSGDepthStencilBuffer is supposed to unregister from the manager");
buffer->free();
buffer->m_manager = nullptr;
}