diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2015-01-26 16:19:58 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-01-28 11:47:10 +0000 |
commit | f446248243d381568e4fa719fb40547b2d7b66ec (patch) | |
tree | 551bacaf5e54f52686c5eb71ae7aebe4c04d572c /src/core/nodes | |
parent | 0b9fe0175de81dc913650ad9fd95a8629a3d7d97 (diff) |
On component removal only deal with the id
Would have been nice to unit test the other end of this event handling
(namely QEntity) but it is tight coupled to ChangeArbiter.
Change-Id: I78a63a237cfac7502a0b2e48118559f5b1bec85a
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/nodes')
-rw-r--r-- | src/core/nodes/qentity.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/core/nodes/qentity.cpp b/src/core/nodes/qentity.cpp index f43d39e41..30afd0e0e 100644 --- a/src/core/nodes/qentity.cpp +++ b/src/core/nodes/qentity.cpp @@ -119,6 +119,9 @@ void QEntity::addComponent(QComponent *comp) } if (d->m_changeArbiter != Q_NULLPTR) { + // Sending a full fledged component in the notification as we'll need + // to know which type of component it was and its properties to create + // the backend object QScenePropertyChangePtr propertyChange(new QScenePropertyChange(ComponentAdded, this)); propertyChange->setPropertyName(QByteArrayLiteral("component")); propertyChange->setValue(QVariant::fromValue(QNodePtr(QNode::clone(comp), &QNodePrivate::nodePtrDeleter))); @@ -136,9 +139,12 @@ void QEntity::removeComponent(QComponent *comp) static_cast<QComponentPrivate *>(QComponentPrivate::get(comp))->removeEntity(this); if (d->m_changeArbiter != Q_NULLPTR) { + // Sending just the component id as it is the only part needed to + // cleanup the backend object. This way we avoid a clone which might + // fail in the case of large scenes. QScenePropertyChangePtr propertyChange(new QScenePropertyChange(ComponentRemoved, this)); - propertyChange->setValue(QVariant::fromValue(QNodePtr(QNode::clone(comp), &QNodePrivate::nodePtrDeleter))); - propertyChange->setPropertyName(QByteArrayLiteral("component")); + propertyChange->setValue(QVariant::fromValue(comp->id())); + propertyChange->setPropertyName(QByteArrayLiteral("componentId")); d->notifyObservers(propertyChange); } |