diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2015-10-01 15:55:17 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2015-10-14 16:01:37 +0000 |
commit | 65d1fbb704706a6701e8e554d555a9b71053c0bc (patch) | |
tree | 7ee3cc4a94dfd48db4d85cda5bf648f3e50cefc3 /src/render | |
parent | c4e63d3eb687d2e7d4267e97d8a6122d0012529a (diff) |
QTechniqueFilter fixes:
- Properly clone the parameters when doing a clone
- Sent QAnnotation QNodeId only, not clones
- Check that a QAnnotation is not already contained when inserting a new one
Change-Id: Ie00410c107b41bebccccd670feb02e2bfd30b84e
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/framegraph/qtechniquefilter.cpp | 28 | ||||
-rw-r--r-- | src/render/framegraph/techniquefilternode.cpp | 10 | ||||
-rw-r--r-- | src/render/framegraph/techniquefilternode_p.h | 2 |
3 files changed, 22 insertions, 18 deletions
diff --git a/src/render/framegraph/qtechniquefilter.cpp b/src/render/framegraph/qtechniquefilter.cpp index e2dd7c081..37fad6f70 100644 --- a/src/render/framegraph/qtechniquefilter.cpp +++ b/src/render/framegraph/qtechniquefilter.cpp @@ -63,6 +63,8 @@ void QTechniqueFilter::copy(const QNode *ref) Q_FOREACH (QAnnotation *crit, other->d_func()->m_requireList) addRequirement(qobject_cast<QAnnotation *>(QNode::clone(crit))); + Q_FOREACH (QParameter *p, other->d_func()->m_parameters) + addParameter(qobject_cast<QParameter *>(QNode::clone(p))); } QTechniqueFilter::QTechniqueFilter(QNode *parent) @@ -90,20 +92,22 @@ QList<QAnnotation *> QTechniqueFilter::criteria() const void QTechniqueFilter::addRequirement(QAnnotation *criterion) { Q_D(QTechniqueFilter); - d->m_requireList.append(criterion); + if (!d->m_requireList.contains(criterion)) { + d->m_requireList.append(criterion); - // 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 - // 2) When the current node is destroyed, it gets destroyed as well - if (!criterion->parent()) - criterion->setParent(this); + // 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 + // 2) When the current node is destroyed, it gets destroyed as well + if (!criterion->parent()) + criterion->setParent(this); - if (d->m_changeArbiter != Q_NULLPTR) { - QScenePropertyChangePtr propertyChange(new QScenePropertyChange(NodeAdded, QSceneChange::Node, id())); - propertyChange->setPropertyName("require"); - propertyChange->setValue(QVariant::fromValue(criterion)); - d->notifyObservers(propertyChange); + if (d->m_changeArbiter != Q_NULLPTR) { + QScenePropertyChangePtr propertyChange(new QScenePropertyChange(NodeAdded, QSceneChange::Node, id())); + propertyChange->setPropertyName("require"); + propertyChange->setValue(QVariant::fromValue(criterion->id())); + d->notifyObservers(propertyChange); + } } } diff --git a/src/render/framegraph/techniquefilternode.cpp b/src/render/framegraph/techniquefilternode.cpp index 9ec764415..7e8ac5723 100644 --- a/src/render/framegraph/techniquefilternode.cpp +++ b/src/render/framegraph/techniquefilternode.cpp @@ -59,7 +59,7 @@ void TechniqueFilter::updateFromPeer(Qt3DCore::QNode *peer) m_filters.clear(); m_parameterPack.clear(); Q_FOREACH (QAnnotation *criterion, filter->criteria()) - appendFilter(criterion); + appendFilter(criterion->id()); Q_FOREACH (QParameter *p, filter->parameters()) m_parameterPack.appendParameter(p->id()); setEnabled(filter->isEnabled()); @@ -75,10 +75,10 @@ QList<Qt3DCore::QNodeId> TechniqueFilter::filters() const return m_filters; } -void TechniqueFilter::appendFilter(QAnnotation *criterion) +void TechniqueFilter::appendFilter(const QNodeId &criterionId) { - if (!m_filters.contains(criterion->id())) - m_filters.append(criterion->id()); + if (!m_filters.contains(criterionId)) + m_filters.append(criterionId); } void TechniqueFilter::removeFilter(const Qt3DCore::QNodeId &criterionId) @@ -99,7 +99,7 @@ void TechniqueFilter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) case NodeAdded: { if (propertyChange->propertyName() == QByteArrayLiteral("require")) - appendFilter(propertyChange->value().value<QAnnotation *>()); + appendFilter(propertyChange->value().value<QNodeId>()); else if (propertyChange->propertyName() == QByteArrayLiteral("parameter")) m_parameterPack.appendParameter(propertyChange->value().value<QNodeId>()); } diff --git a/src/render/framegraph/techniquefilternode_p.h b/src/render/framegraph/techniquefilternode_p.h index 59ffb9572..59688a557 100644 --- a/src/render/framegraph/techniquefilternode_p.h +++ b/src/render/framegraph/techniquefilternode_p.h @@ -80,7 +80,7 @@ public: void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; private: - void appendFilter(QAnnotation *criterion); + void appendFilter(const Qt3DCore::QNodeId &criterionId); void removeFilter(const Qt3DCore::QNodeId &criterionId); QList<Qt3DCore::QNodeId> m_filters; |