diff options
Diffstat (limited to 'src/core/nodes')
-rw-r--r-- | src/core/nodes/nodes.pri | 27 | ||||
-rw-r--r-- | src/core/nodes/qbackendnode.cpp | 2 | ||||
-rw-r--r-- | src/core/nodes/qentity.cpp | 2 | ||||
-rw-r--r-- | src/core/nodes/qnode.cpp | 7 | ||||
-rw-r--r-- | src/core/nodes/qnode_p.h | 11 |
5 files changed, 14 insertions, 35 deletions
diff --git a/src/core/nodes/nodes.pri b/src/core/nodes/nodes.pri deleted file mode 100644 index 097f1cbc7..000000000 --- a/src/core/nodes/nodes.pri +++ /dev/null @@ -1,27 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qnode.h \ - $$PWD/qnode_p.h \ - $$PWD/qcomponent.h \ - $$PWD/qcomponent_p.h \ - $$PWD/qentity.h \ - $$PWD/qentity_p.h \ - $$PWD/qbackendnode_p.h \ - $$PWD/qbackendnode.h \ - $$PWD/qnodeid.h \ - $$PWD/qnodevisitor_p.h \ - $$PWD/propertychangehandler_p.h \ - $$PWD/qdestructionidandtypecollector_p.h \ - $$PWD/qabstractnodefactory_p.h - -SOURCES += \ - $$PWD/qnode.cpp \ - $$PWD/qcomponent.cpp \ - $$PWD/qentity.cpp \ - $$PWD/qbackendnode.cpp \ - $$PWD/qnodeid.cpp \ - $$PWD/qnodevisitor.cpp \ - $$PWD/qabstractnodefactory.cpp \ - $$PWD/propertychangehandler.cpp \ - $$PWD/qdestructionidandtypecollector.cpp diff --git a/src/core/nodes/qbackendnode.cpp b/src/core/nodes/qbackendnode.cpp index 7a8aaa45e..ed5363a70 100644 --- a/src/core/nodes/qbackendnode.cpp +++ b/src/core/nodes/qbackendnode.cpp @@ -156,7 +156,7 @@ QBackendNode::Mode QBackendNode::mode() const noexcept * \param frontEnd * \param firstTime * - * This is called by the aspect when a \a frontEnd node needs to synchronize it's changes + * This is called by the aspect when a \a frontEnd node needs to synchronize its changes * with the backend (normally due to property changes). * * \a firstTime will be true if the backend node was just created diff --git a/src/core/nodes/qentity.cpp b/src/core/nodes/qentity.cpp index f26da3bea..a77ec09ca 100644 --- a/src/core/nodes/qentity.cpp +++ b/src/core/nodes/qentity.cpp @@ -139,7 +139,7 @@ QEntity::QEntity(QEntityPrivate &dd, QNode *parent) QEntity::~QEntity() { // remove all component aggregations - Q_D(const QEntity); + Q_D(QEntity); // to avoid hammering m_components by repeated removeComponent() // calls below, move all contents out, so the removeOne() calls in // removeComponent() don't actually remove something: 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(); diff --git a/src/core/nodes/qnode_p.h b/src/core/nodes/qnode_p.h index faca3db70..b2a61fbbe 100644 --- a/src/core/nodes/qnode_p.h +++ b/src/core/nodes/qnode_p.h @@ -86,7 +86,7 @@ public: // If the node is destoyed, we make sure not to keep a dangling pointer to it Q_Q(QNode); auto f = [q, func]() { (static_cast<Caller *>(q)->*func)(nullptr); }; - m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); + m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, q, f)}); } template<typename Caller, typename NodeType> @@ -95,7 +95,7 @@ public: // If the node is destoyed, we make sure not to keep a dangling pointer to it Q_Q(QNode); auto f = [q, func, node]() { (static_cast<Caller *>(q)->*func)(node); }; - m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); + m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, q, f)}); } template<typename Caller, typename NodeType> @@ -104,7 +104,7 @@ public: // If the node is destoyed, we make sure not to keep a dangling pointer to it Q_Q(QNode); auto f = [q, func, node]() { (static_cast<Caller *>(q)->*func)(node); }; - m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); + m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, q, f)}); } template<typename Caller, typename ValueType> @@ -117,15 +117,16 @@ public: // If the node is destoyed, we make sure not to keep a dangling pointer to it Q_Q(QNode); auto f = [q, func, resetValue]() { (static_cast<Caller *>(q)->*func)(resetValue); }; - m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); + m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, q, f)}); } template<typename Caller, typename NodeType> void registerPrivateDestructionHelper(NodeType *node, DestructionFunctionPointer<Caller, NodeType> func) { + Q_Q(QNode); // If the node is destoyed, we make sure not to keep a dangling pointer to it auto f = [this, func, node]() { (static_cast<Caller *>(this)->*func)(node); }; - m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, f)}); + m_destructionConnections.push_back({node, QObject::connect(node, &QNode::nodeDestroyed, q, f)}); } void unregisterDestructionHelper(QNode *node) |