summaryrefslogtreecommitdiffstats
path: root/src/core/nodes/qnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/nodes/qnode.cpp')
-rw-r--r--src/core/nodes/qnode.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/nodes/qnode.cpp b/src/core/nodes/qnode.cpp
index 5ba46a7c5..3c2bf3259 100644
--- a/src/core/nodes/qnode.cpp
+++ b/src/core/nodes/qnode.cpp
@@ -12,6 +12,7 @@
#include <QtCore/QEvent>
#include <QtCore/QMetaObject>
#include <QtCore/QMetaProperty>
+#include <QtCore/QThread>
#include <Qt3DCore/private/corelogging_p.h>
#include <Qt3DCore/private/qdestructionidandtypecollector_p.h>
@@ -848,7 +849,10 @@ void NodePostConstructorInit::addNode(QNode *node)
while (nextNode != nullptr && !m_nodesToConstruct.contains(QNodePrivate::get(nextNode)))
nextNode = nextNode->parentNode();
- if (!nextNode) {
+ // An ancestor in the m_nodesToConstruct may already have been created (m_hasBackendNode)
+ // at this point (e.g. when a QComponent calls _q_ensureBackendNodeCreated()),
+ // that's why we also queue a creation request in this case.
+ if (!nextNode || QNodePrivate::get(nextNode)->m_hasBackendNode) {
m_nodesToConstruct.append(QNodePrivate::get(node));
if (!m_requestedProcessing){
QMetaObject::invokeMethod(this, "processNodes", Qt::QueuedConnection);
@@ -877,6 +881,7 @@ void NodePostConstructorInit::removeNode(QNode *node)
*/
void NodePostConstructorInit::processNodes()
{
+ Q_ASSERT(thread() == QThread::currentThread());
m_requestedProcessing = false;
while (!m_nodesToConstruct.empty()) {
auto node = m_nodesToConstruct.takeFirst();