summaryrefslogtreecommitdiffstats
path: root/src/quick3d/quick3d/items
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-07-21 10:15:18 +0200
committerPaul Lemire <paul.lemire@kdab.com>2015-07-25 10:07:33 +0000
commit37f9d95b848127706f417f91254fad3addcc40cd (patch)
tree85edd9ed9818a9df314e96090a0170cb35c86960 /src/quick3d/quick3d/items
parent08e74c9bcdce4b1708043c412ef9449bd6987c4b (diff)
Quick3DEntityLoader: fix insert the item when it is fully created
QQmlIncubator::setInitialState is called after the object is created but the bindings aren't evaluated at this point Instead use QQmlIncubator::statusChanged and check for a status Ready at which point all the bindings have been properly evaluated Task-number: QTBUG-47281 Change-Id: I1dc6e5a76b0bb42cc012b0e5bc980701813791f3 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/quick3d/quick3d/items')
-rw-r--r--src/quick3d/quick3d/items/quick3dentityloader.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/quick3d/quick3d/items/quick3dentityloader.cpp b/src/quick3d/quick3d/items/quick3dentityloader.cpp
index 639451861..1fe8945e1 100644
--- a/src/quick3d/quick3d/items/quick3dentityloader.cpp
+++ b/src/quick3d/quick3d/items/quick3dentityloader.cpp
@@ -59,16 +59,30 @@ public:
}
protected:
- void setInitialState(QObject *object) Q_DECL_OVERRIDE
+ void statusChanged(Status status) Q_DECL_FINAL
{
Quick3DEntityLoaderPrivate *priv = Quick3DEntityLoaderPrivate::get(m_loader);
- Q_ASSERT(priv->m_entity == Q_NULLPTR);
- priv->m_entity = qobject_cast<QEntity *>(object);
- Q_ASSERT(priv->m_entity != Q_NULLPTR);
- priv->m_entity->setParent(m_loader);
-
- emit m_loader->entityChanged();
+ switch (status) {
+ case Status::Ready: {
+ Q_ASSERT(priv->m_entity == Q_NULLPTR);
+ priv->m_entity = qobject_cast<QEntity *>(object());
+ Q_ASSERT(priv->m_entity != Q_NULLPTR);
+ priv->m_entity->setParent(m_loader);
+ emit m_loader->entityChanged();
+ break;
+ }
+
+ case Status::Error: {
+ QQmlEnginePrivate::warning(qmlEngine(m_loader), errors());
+ priv->clear();
+ emit m_loader->entityChanged();
+ break;
+ }
+
+ default:
+ break;
+ }
}
private: