diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-05-20 17:11:37 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-05-23 16:31:55 +0000 |
commit | 073930f2ef030b3019c323999d910185f4639d9b (patch) | |
tree | 0c2bba252f7a92d4f3841fbe42eeca27e2a8a838 /src/render/framegraph/qtechniquefilter.cpp | |
parent | 15dace7c02bc5acdf02f94c8be08fec1a792383c (diff) |
Shared node bookkeeping
Any time a property references a QNode there is a risk that the node gets
destroyed and then the property is left pointing to a dangling pointer.
To handle such cases, setters of such properties are able to use a helper
that internally connect QObject::destroyed signal to a setter removal method.
Change-Id: I42428c851d0e3d2d88ab0cf6a5b75605334ec648
Task-number: QTBUG-53456
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/framegraph/qtechniquefilter.cpp')
-rw-r--r-- | src/render/framegraph/qtechniquefilter.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/render/framegraph/qtechniquefilter.cpp b/src/render/framegraph/qtechniquefilter.cpp index 49ac03041..07707866c 100644 --- a/src/render/framegraph/qtechniquefilter.cpp +++ b/src/render/framegraph/qtechniquefilter.cpp @@ -85,6 +85,9 @@ void QTechniqueFilter::addMatch(QFilterKey *filterKey) if (!d->m_matchList.contains(filterKey)) { d->m_matchList.append(filterKey); + // Ensures proper bookkeeping + d->registerDestructionHelper(filterKey, &QTechniqueFilter::addMatch, d->m_matchList); + // We need to add it as a child of the current node if it has been declared inline // Or not previously added as a child of the current node so that // 1) The backend gets notified about it's creation @@ -110,6 +113,8 @@ void QTechniqueFilter::removeMatch(QFilterKey *filterKey) d->notifyObservers(change); } d->m_matchList.removeOne(filterKey); + // Remove bookkeeping connection + d->unregisterDestructionHelper(filterKey); } void QTechniqueFilter::addParameter(QParameter *parameter) @@ -119,6 +124,9 @@ void QTechniqueFilter::addParameter(QParameter *parameter) if (!d->m_parameters.contains(parameter)) { d->m_parameters.append(parameter); + // Ensures proper bookkeeping + d->registerDestructionHelper(parameter, &QTechniqueFilter::removeParameter, d->m_parameters); + // We need to add it as a child of the current node if it has been declared inline // Or not previously added as a child of the current node so that // 1) The backend gets notified about it's creation @@ -144,6 +152,8 @@ void QTechniqueFilter::removeParameter(QParameter *parameter) d->notifyObservers(change); } d->m_parameters.removeOne(parameter); + // Remove bookkeeping connection + d->unregisterDestructionHelper(parameter); } QVector<QParameter *> QTechniqueFilter::parameters() const |