From 7aab0e3b850cc17735ac19ab7a6e7db2bac1cb83 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 10 Dec 2017 16:20:08 +0100 Subject: Add QBlitFramebuffer auto-parenting behavior As is common with other nodes. Task-number: QTBUG-65081 Change-Id: I12ccd2fb5344e116f2f5333b73edb4562799543d Reviewed-by: Sean Harmer --- src/render/framegraph/qblitframebuffer.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/render/framegraph') diff --git a/src/render/framegraph/qblitframebuffer.cpp b/src/render/framegraph/qblitframebuffer.cpp index 505bab96c..629ae04f6 100644 --- a/src/render/framegraph/qblitframebuffer.cpp +++ b/src/render/framegraph/qblitframebuffer.cpp @@ -121,7 +121,21 @@ void QBlitFramebuffer::setSource(QRenderTarget *source) { Q_D(QBlitFramebuffer); if (d->m_source != source) { + if (d->m_source) { + // Remove bookkeeping connection + d->unregisterDestructionHelper(d->m_source); + } + d->m_source = source; + + if (d->m_source) { + // Ensures proper bookkeeping. Calls us back with nullptr in case the rt gets destroyed. + d->registerDestructionHelper(d->m_source, &QBlitFramebuffer::setSource, d->m_source); + + if (!d->m_source->parent()) + d->m_source->setParent(this); + } + emit sourceChanged(); } } @@ -130,7 +144,21 @@ void QBlitFramebuffer::setDestination(QRenderTarget *destination) { Q_D(QBlitFramebuffer); if (d->m_destination != destination) { + if (d->m_destination) { + // Remove bookkeeping connection + d->unregisterDestructionHelper(d->m_destination); + } + d->m_destination = destination; + + if (d->m_destination) { + // Ensures proper bookkeeping. Calls us back with nullptr in case the rt gets destroyed. + d->registerDestructionHelper(d->m_destination, &QBlitFramebuffer::setDestination, d->m_destination); + + if (!d->m_destination->parent()) + d->m_destination->setParent(this); + } + emit destinationChanged(); } } -- cgit v1.2.3