diff options
author | Svenn-Arne Dragly <s@dragly.com> | 2019-02-22 13:50:30 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2019-02-22 15:00:31 +0000 |
commit | 3de900a10c6fd051ba54727be2fd1fe47ed10481 (patch) | |
tree | de030e365dec53d02d6707601078dd9fc48ef773 /src/core/nodes/qnode.cpp | |
parent | 799bb8615c86b7713351851c6013821b523f8aa2 (diff) |
Make sure backend node is created when component is added to Entityv5.12.2
In addition, the parent of the component and all further ancestors need
to be registered on the backend. We do this by calling
QNodePrivate::_q_postConstructorInit on all these nodes.
Also add autotest that triggers the case referenced in QTBUG-72236 to
avoid regressions.
Change-Id: Ibf8f43654d145ea8b8082b2f30123ea65e42ff55
Fixes: QTBUG-72236
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Reviewed-by: James Turner <james.turner@kdab.com>
Diffstat (limited to 'src/core/nodes/qnode.cpp')
-rw-r--r-- | src/core/nodes/qnode.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/nodes/qnode.cpp b/src/core/nodes/qnode.cpp index 8143ccc75..c2373b805 100644 --- a/src/core/nodes/qnode.cpp +++ b/src/core/nodes/qnode.cpp @@ -506,6 +506,29 @@ void QNodePrivate::setArbiter(QLockableObserverInterface *arbiter) } /*! + * \internal + * Makes sure this node has a backend by traversing the tree up to the most distant ancestor + * without a backend node and initializing that node. This is done to make sure the parent nodes + * are always created before the child nodes, since child nodes reference parent nodes at creation + * time. + */ +void QNodePrivate::_q_ensureBackendNodeCreated() +{ + if (m_hasBackendNode) + return; + + Q_Q(QNode); + + QNode *nextNode = q; + QNode *topNodeWithoutBackend = nullptr; + while (nextNode != nullptr && !QNodePrivate::get(nextNode)->m_hasBackendNode) { + topNodeWithoutBackend = nextNode; + nextNode = nextNode->parentNode(); + } + QNodePrivate::get(topNodeWithoutBackend)->_q_postConstructorInit(); +} + +/*! \class Qt3DCore::QNode \inherits QObject |