diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2016-04-10 17:05:36 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-04-12 12:48:00 +0000 |
commit | 5dfc07541d1d63563114814d799b1b6540ef021f (patch) | |
tree | 82ba41ecb9e079dd682189dff18c6ab60470811f /src | |
parent | 52892d88f1c5c20f2cf483470db234d2849885df (diff) |
Update QScene in the no cloning code paths
Added some todo's to investigate folding the scene updates into the
tree traversal used to build the creation/destruction events.
Change-Id: Ia05bca989bc5f44d29e85d9a09c3d25cf32f0776
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/nodes/qnode.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/nodes/qnode.cpp b/src/core/nodes/qnode.cpp index 11cd8fb3f..93107f49e 100644 --- a/src/core/nodes/qnode.cpp +++ b/src/core/nodes/qnode.cpp @@ -118,6 +118,9 @@ void QNodePrivate::_q_addChild(QNode *childNode) // Handle Entity - Components visitor.traverse(childNode, this, &QNodePrivate::addEntityComponentToScene); } else { + if (!m_scene) + return; + QNodeCreatedChangeGenerator generator(childNode); const auto creationChanges = generator.creationChanges(); // TODO: Wrap all creation changes into a single aggregate change to avoid @@ -125,6 +128,13 @@ void QNodePrivate::_q_addChild(QNode *childNode) // all of the aspects. for (const auto &change : creationChanges) notifyObservers(change); + + // Update the scene + // TODO: Fold this into the QNodeCreatedChangeGenerator so we don't have to + // traverse the sub tree three times! + QNodeVisitor visitor; + visitor.traverse(childNode, this, &QNodePrivate::setSceneHelper); + visitor.traverse(childNode, this, &QNodePrivate::addEntityComponentToScene); } } @@ -172,6 +182,12 @@ void QNodePrivate::_q_removeChild(QNode *childNode) auto destroyedChange = QNodeDestroyedChangePtr::create(childNode, collector.subtreeIdsAndTypes()); notifyObservers(destroyedChange); } + + // Update the scene + // TODO: Fold this into the QNodeCreatedChangeGenerator so we don't have to + // traverse the sub tree twice + QNodeVisitor visitor; + visitor.traverse(childNode, this, &QNodePrivate::unsetSceneHelper); } } |