diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-08-14 11:50:10 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-08-29 08:32:29 +0200 |
commit | c1b1bbbb72a9d0c11d92c8cdb998c52d515932da (patch) | |
tree | ea126554b3dde2505deb10b1a5b381fd82384b13 /tests/auto/render/commons/testaspect.cpp | |
parent | fa801839d384e9d6eea09350433e354cf753c267 (diff) |
Use sync method when initializing new backend nodes
If the node type supports syncing, use that rather than the creation
message. The message is still needed since that is passed to the
instantiation functor (none of qt3d's classes appear to use anything
but the node id, but can't be sure no other classes do, and can't add
other virtual method without breaking BC).
Change-Id: Id99f448070b8722a7809b968798772c9eb3c8397
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'tests/auto/render/commons/testaspect.cpp')
-rw-r--r-- | tests/auto/render/commons/testaspect.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/tests/auto/render/commons/testaspect.cpp b/tests/auto/render/commons/testaspect.cpp index ffe9fb0e6..8be6a7833 100644 --- a/tests/auto/render/commons/testaspect.cpp +++ b/tests/auto/render/commons/testaspect.cpp @@ -35,11 +35,37 @@ ****************************************************************************/ #include "testaspect.h" +#include <Qt3DCore/private/qnodevisitor_p.h> +#include <Qt3DCore/private/qnode_p.h> QT_BEGIN_NAMESPACE namespace Qt3DRender { +QVector<Qt3DCore::QNode *> getNodesForCreation(Qt3DCore::QNode *root) +{ + using namespace Qt3DCore; + + QVector<QNode *> nodes; + Qt3DCore::QNodeVisitor visitor; + visitor.traverse(root, [&nodes](QNode *node) { + nodes.append(node); + + // Store the metaobject of the node in the QNode so that we have it available + // to us during destruction in the QNode destructor. This allows us to send + // the QNodeId and the metaobject as typeinfo to the backend aspects so they + // in turn can find the correct QBackendNodeMapper object to handle the destruction + // of the corresponding backend nodes. + QNodePrivate *d = QNodePrivate::get(node); + d->m_typeInfo = const_cast<QMetaObject*>(QNodePrivate::findStaticMetaObject(node->metaObject())); + + // Mark this node as having been handled for creation so that it is picked up + d->m_hasBackendNode = true; + }); + + return nodes; +} + TestAspect::TestAspect(Qt3DCore::QNode *root) : Qt3DRender::QRenderAspect(Qt3DRender::QRenderAspect::Synchronous) , m_jobManager(new Qt3DCore::QAspectJobManager()) @@ -47,11 +73,10 @@ TestAspect::TestAspect(Qt3DCore::QNode *root) Qt3DCore::QAbstractAspectPrivate::get(this)->m_jobManager = m_jobManager.data(); QRenderAspect::onRegistered(); - const Qt3DCore::QNodeCreatedChangeGenerator generator(root); - const QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = generator.creationChanges(); + const QVector<Qt3DCore::QNode *> nodes = getNodesForCreation(root); - for (const Qt3DCore::QNodeCreatedChangeBasePtr change : creationChanges) - d_func()->createBackendNode(change); + for (Qt3DCore::QNode *node : nodes) + d_func()->createBackendNode(node); } TestAspect::~TestAspect() |