summaryrefslogtreecommitdiffstats
path: root/src/core/nodes/qcomponent.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-06-29 20:32:37 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-06-29 20:32:37 +0200
commit57e982442a4df1fd3a4fd063964aeb3895ae3e12 (patch)
tree55ee517c952eb299c5f41baf629f62bf231ea3f1 /src/core/nodes/qcomponent.cpp
parent8f58119cd18d69fac28528f0a7536cb9fccc15e3 (diff)
parentcdd39567c3b0bd0f9440dead548954d5230a611f (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: .qmake.conf src/render/defaults/qforwardrenderer.cpp src/render/doc/qt3drender.qdocconf Change-Id: I1c4a15d2b57980dca82fa420ab6ef8c48c049a2c
Diffstat (limited to 'src/core/nodes/qcomponent.cpp')
-rw-r--r--src/core/nodes/qcomponent.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/nodes/qcomponent.cpp b/src/core/nodes/qcomponent.cpp
index d9a99d50d..71acb6a03 100644
--- a/src/core/nodes/qcomponent.cpp
+++ b/src/core/nodes/qcomponent.cpp
@@ -38,7 +38,7 @@
#include "qcomponent_p.h"
#include "qentity.h"
#include "qentity_p.h"
-
+#include "qsceneinterface.h"
#include <Qt3DCore/qscenepropertychange.h>
QT_BEGIN_NAMESPACE
@@ -60,6 +60,12 @@ void QComponentPrivate::addEntity(QEntity *entity)
{
m_entities.append(entity);
+ if (m_scene != Q_NULLPTR) {
+ if (!m_shareable && !m_scene->entitiesForComponent(m_id).isEmpty())
+ qWarning() << "Trying to assign a non shareable component to more than one Entity";
+ m_scene->addEntityForComponent(m_id, entity->id());
+ }
+
// We notify only if we have a QChangeArbiter
if (m_changeArbiter != Q_NULLPTR) {
Q_Q(QComponent);
@@ -81,6 +87,9 @@ void QComponentPrivate::removeEntity(QEntity *entity)
notifyObservers(e);
}
+ if (m_scene != Q_NULLPTR)
+ m_scene->removeEntityForComponent(m_id, entity->id());
+
m_entities.removeAll(entity);
}
@@ -116,6 +125,8 @@ QComponent::QComponent(QNode *parent)
QComponent::~QComponent()
{
+ Q_ASSERT_X(QNodePrivate::get(this)->m_wasCleanedUp, Q_FUNC_INFO, "QNode::cleanup should have been called by now. A Qt3D::QComponent subclass didn't call QNode::cleanup in its destructor");
+
Q_FOREACH (QEntity *entity, entities()) {
QEntityPrivate *entityPimpl = dynamic_cast<QEntityPrivate *>(QEntityPrivate::get(entity));
if (entityPimpl)