diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-05-24 12:09:44 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-05-24 12:10:02 +0100 |
commit | 77d294db076dac19e8b549b445ffede9f7260c84 (patch) | |
tree | 828ee7a6862ec5c0bd24f97cb540625a2c647376 /src/render/io/qsceneloader.cpp | |
parent | 59f8fec8a41606b3185fe3a4e276978e3e1ed5ef (diff) | |
parent | 939b9b4b7591e8a421cf048a0a84ed3e75d81d21 (diff) |
Merge branch 'dev' into wip/animationwip/animation
Change-Id: I6e770609c90a7745d08fa4e2f424e865678c5d6f
Diffstat (limited to 'src/render/io/qsceneloader.cpp')
-rw-r--r-- | src/render/io/qsceneloader.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/render/io/qsceneloader.cpp b/src/render/io/qsceneloader.cpp index b9408298f..3bc842c3d 100644 --- a/src/render/io/qsceneloader.cpp +++ b/src/render/io/qsceneloader.cpp @@ -198,7 +198,8 @@ void QSceneLoaderPrivate::populateEntityMap(QEntity *parentEntity) { // Topmost parent entity is not considered part of the scene as that is typically // an unnamed entity inserted by importer. - for (auto childNode : parentEntity->childNodes()) { + const QNodeVector childNodes = parentEntity->childNodes(); + for (auto childNode : childNodes) { auto childEntity = qobject_cast<QEntity *>(childNode); if (childEntity) { m_entityMap.insert(childEntity->objectName(), childEntity); @@ -207,6 +208,17 @@ void QSceneLoaderPrivate::populateEntityMap(QEntity *parentEntity) } } +void QSceneLoaderPrivate::setStatus(QSceneLoader::Status status) +{ + if (m_status != status) { + Q_Q(QSceneLoader); + m_status = status; + const bool wasBlocked = q->blockNotifications(true); + emit q->statusChanged(status); + q->blockNotifications(wasBlocked); + } +} + /*! The constructor creates an instance with the specified \a parent. */ @@ -253,7 +265,7 @@ void QSceneLoader::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) d->populateEntityMap(d->m_subTreeRoot); } } else if (e->propertyName() == QByteArrayLiteral("status")) { - setStatus(e->value().value<QSceneLoader::Status>()); + d->setStatus(e->value().value<QSceneLoader::Status>()); } } } @@ -328,7 +340,7 @@ QStringList QSceneLoader::entityNames() const \sa Qt3DRender::QSceneLoader::ComponentType */ /*! - Returns a component matching \a componentType of a loaded entity with an \a objectName matching + Returns a component matching \a componentType of a loaded entity with an objectName matching the \a entityName. If the entity has multiple matching components, the first match in the component list of the entity is returned. @@ -338,7 +350,8 @@ QComponent *QSceneLoader::component(const QString &entityName, QSceneLoader::ComponentType componentType) const { QEntity *e = entity(entityName); - for (auto component : e->components()) { + const QComponentVector components = e->components(); + for (auto component : components) { switch (componentType) { case GeometryRendererComponent: if (qobject_cast<Qt3DRender::QGeometryRenderer *>(component)) @@ -371,12 +384,7 @@ QComponent *QSceneLoader::component(const QString &entityName, void QSceneLoader::setStatus(QSceneLoader::Status status) { Q_D(QSceneLoader); - if (d->m_status != status) { - d->m_status = status; - const bool wasBlocked = blockNotifications(true); - emit statusChanged(status); - blockNotifications(wasBlocked); - } + d->setStatus(status); } Qt3DCore::QNodeCreatedChangeBasePtr QSceneLoader::createNodeCreationChange() const |