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/updatemeshtrianglelistjob | |
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/updatemeshtrianglelistjob')
-rw-r--r-- | tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp b/tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp index f3fc2ad9b..71576d495 100644 --- a/tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp +++ b/tests/auto/render/updatemeshtrianglelistjob/tst_updatemeshtrianglelistjob.cpp @@ -38,12 +38,37 @@ #include <Qt3DRender/private/qrenderaspect_p.h> #include <Qt3DCore/qpropertyupdatedchange.h> #include <Qt3DCore/private/qnodecreatedchangegenerator_p.h> +#include <Qt3DCore/private/qnodevisitor_p.h> #include "qmlscenereader.h" QT_BEGIN_NAMESPACE namespace Qt3DRender { // Needs to be in that namespace to be friend with QRenderAspect +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; +} + class TestAspect : public Qt3DRender::QRenderAspect { public: @@ -53,10 +78,8 @@ public: { Qt3DRender::QRenderAspect::onRegistered(); - const Qt3DCore::QNodeCreatedChangeGenerator generator(root); - const QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = generator.creationChanges(); - - d_func()->setRootAndCreateNodes(qobject_cast<Qt3DCore::QEntity *>(root), creationChanges); + const QVector<Qt3DCore::QNode *> nodes = getNodesForCreation(root); + d_func()->setRootAndCreateNodes(qobject_cast<Qt3DCore::QEntity *>(root), nodes); Qt3DRender::Render::Entity *rootEntity = nodeManagers()->lookupResource<Qt3DRender::Render::Entity, Render::EntityManager>(rootEntityId()); Q_ASSERT(rootEntity); |