diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-08-11 11:54:46 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-08-23 06:29:01 +0000 |
commit | b9c90bb81a9474ec05565be866c403f2a3a26f2f (patch) | |
tree | 8bc8ee932f547fb1d7cd0a8b6e5b898cd1cd6180 /src/render/jobs/loadscenejob.cpp | |
parent | 0f2dbaf025513ce906fc08b5153dea15142ff35a (diff) |
QSceneLoader: status is updated from the backend
Change-Id: I52159b0fa78ab915e73c2dc84bda9bccc3dbd0ef
Task-number: QTBUG-54889
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/jobs/loadscenejob.cpp')
-rw-r--r-- | src/render/jobs/loadscenejob.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/render/jobs/loadscenejob.cpp b/src/render/jobs/loadscenejob.cpp index 758e0b135..3111e1ba3 100644 --- a/src/render/jobs/loadscenejob.cpp +++ b/src/render/jobs/loadscenejob.cpp @@ -44,6 +44,7 @@ #include <Qt3DCore/qentity.h> #include <Qt3DRender/private/job_common_p.h> #include <Qt3DRender/private/qsceneiohandler_p.h> +#include <Qt3DRender/qsceneloader.h> QT_BEGIN_NAMESPACE @@ -64,29 +65,41 @@ void LoadSceneJob::run() // Iterate scene IO handlers until we find one that can handle this file type Qt3DCore::QEntity *sceneSubTree = nullptr; + Scene *scene = m_managers->sceneManager()->lookupResource(m_sceneComponent); + Q_ASSERT(scene); + + // Reset status + scene->setStatus(QSceneLoader::None); + // Perform the loading only if the source wasn't explicitly set to empty if (!m_source.isEmpty()) { for (QSceneIOHandler *sceneIOHandler : qAsConst(m_sceneIOHandlers)) { if (!sceneIOHandler->isFileTypeSupported(m_source)) continue; + // If the file type is supported -> enter Loading status + scene->setStatus(QSceneLoader::Loading); + // File type is supported, try to load it sceneIOHandler->setSource(m_source); Qt3DCore::QEntity *sub = sceneIOHandler->scene(); if (sub) { sceneSubTree = sub; + // Successfully built a subtree + scene->setStatus(QSceneLoader::Ready); break; + } else { + // Tree wasn't build so something went wrong obviously + scene->setStatus(QSceneLoader::Error); } } } - // Set clone of sceneTree in sceneComponent. This will move the sceneSubTree - // to the QCoreApplication thread which is where the frontend object tree lives. - Scene *scene = m_managers->sceneManager()->lookupResource(m_sceneComponent); // If the sceneSubTree is null it will trigger the frontend to unload // any subtree it may hold - if (scene) - scene->setSceneSubtree(sceneSubTree); + // Set clone of sceneTree in sceneComponent. This will move the sceneSubTree + // to the QCoreApplication thread which is where the frontend object tree lives. + scene->setSceneSubtree(sceneSubTree); } } // namespace Render |