diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2018-07-11 15:50:10 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2018-07-18 07:46:28 +0000 |
commit | 5376853866e49b5a6841c6c41affef5a3d3d4bb5 (patch) | |
tree | d9460391f5811c75947ad9ba0bb9b0c308b29f95 /src/core/nodes | |
parent | c39e20dcc693b525f2ee2259e864487d664c3856 (diff) |
QNode: _q_postConstructorInit set scene on whole subtree
_q_postConstrutorInit is called in a deferred invocation when constructing a
Node with a parent. If several nodes are created that way, the
_q_postConstructorInit call from the node which parents the other will
actually build the node creation changes for the whole subtree and incidently
prevent the _q_postConstructorInit invocation for the children to do anything
(including setting the scene). Therefore _q_postConstructorInit should set the
scene on all the Node it will be creating creation changes for.
Change-Id: I07d4e80675758b9701cc941881f1faaa1c89af4b
Task-number: QTBUG-69352
Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/nodes')
-rw-r--r-- | src/core/nodes/qnode.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/nodes/qnode.cpp b/src/core/nodes/qnode.cpp index ff7a1b2ce..9c069f936 100644 --- a/src/core/nodes/qnode.cpp +++ b/src/core/nodes/qnode.cpp @@ -188,9 +188,14 @@ void QNodePrivate::_q_postConstructorInit() if (!parentNode) return; - - if (m_scene) - m_scene->addObservable(q); // Sets the m_changeArbiter to that of the scene + // Set the scene on this node and all children it references so that all + // children have a scene set since notifyCreationChanges will set + // m_hasBackendNode to true for all children, which would prevent them from + // ever having their scene set + if (m_scene) { + QNodeVisitor visitor; + visitor.traverse(q, parentNode->d_func(), &QNodePrivate::setSceneHelper); + } // Let the backend know we have been added to the scene notifyCreationChange(); |