summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire350@gmail.com>2017-02-06 10:37:02 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-02-12 19:31:40 +0000
commitc8308fd1fcf58f8b72dff8982abaeae5ad361fdf (patch)
tree723ff2d7aaa505803f56436abd690763f24e2f7a
parent5c6d6aa44f5fe327b61d2209f30eb40405c1596d (diff)
Quick3DEntity: use dedicated list of QML components
So that we can add layers to prebuilt Entities Change-Id: I608c3dfcb6351c95f4cd373f14bea0f3a247508c Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/quick3d/quick3d/items/quick3dentity.cpp6
-rw-r--r--src/quick3d/quick3d/items/quick3dentity_p.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/src/quick3d/quick3d/items/quick3dentity.cpp b/src/quick3d/quick3d/items/quick3dentity.cpp
index ebc92e843..0a95815af 100644
--- a/src/quick3d/quick3d/items/quick3dentity.cpp
+++ b/src/quick3d/quick3d/items/quick3dentity.cpp
@@ -92,6 +92,7 @@ void Quick3DEntity::qmlAppendComponent(QQmlListProperty<QComponent> *list, QComp
if (comp == nullptr)
return;
Quick3DEntity *self = static_cast<Quick3DEntity *>(list->object);
+ self->m_managedComponents.push_back(comp);
self->parentEntity()->addComponent(comp);
}
@@ -110,10 +111,9 @@ int Quick3DEntity::qmlComponentsCount(QQmlListProperty<QComponent> *list)
void Quick3DEntity::qmlClearComponents(QQmlListProperty<QComponent> *list)
{
Quick3DEntity *self = static_cast<Quick3DEntity *>(list->object);
- const QComponentVector components = self->parentEntity()->components();
- for (QComponent *comp : components) {
+ for (QComponent *comp : qAsConst(self->m_managedComponents))
self->parentEntity()->removeComponent(comp);
- }
+ self->m_managedComponents.clear();
}
} // namespace Quick
diff --git a/src/quick3d/quick3d/items/quick3dentity_p.h b/src/quick3d/quick3d/items/quick3dentity_p.h
index eb716a0c3..519ea4bd1 100644
--- a/src/quick3d/quick3d/items/quick3dentity_p.h
+++ b/src/quick3d/quick3d/items/quick3dentity_p.h
@@ -82,6 +82,8 @@ private:
static QComponent *qmlComponentAt(QQmlListProperty<Qt3DCore::QComponent> *list, int index);
static int qmlComponentsCount(QQmlListProperty<Qt3DCore::QComponent> *list);
static void qmlClearComponents(QQmlListProperty<Qt3DCore::QComponent> *list);
+
+ QVector<Qt3DCore::QComponent *> m_managedComponents;
};
} // namespace Quick