diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-08-11 10:10:42 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-08-11 20:17:54 +0000 |
commit | c7b56c2ec5abb8fb27a93ee191c5760f1a42083c (patch) | |
tree | 3523e07332af3e6f377bff5c537ba20238eb73f6 /src/render/jobs/loadscenejob.cpp | |
parent | 71edf63d457de56740578939a62645ffbc71e040 (diff) |
LoadSceneJob: always call Scene::setSubTree()
Even if the subTree is null as that is needed for the frontend
to destroy any previous subtree that may have been created.
Change-Id: I27171ab0dc8576af2f3c8b7499265b52c2649c67
Task-number: QTBUG-54889
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/jobs/loadscenejob.cpp')
-rw-r--r-- | src/render/jobs/loadscenejob.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/render/jobs/loadscenejob.cpp b/src/render/jobs/loadscenejob.cpp index d0d8be9ef..758e0b135 100644 --- a/src/render/jobs/loadscenejob.cpp +++ b/src/render/jobs/loadscenejob.cpp @@ -63,23 +63,29 @@ void LoadSceneJob::run() { // Iterate scene IO handlers until we find one that can handle this file type Qt3DCore::QEntity *sceneSubTree = nullptr; - for (QSceneIOHandler *sceneIOHandler : qAsConst(m_sceneIOHandlers)) { - if (!sceneIOHandler->isFileTypeSupported(m_source)) - continue; - // File type is supported, try to load it - sceneIOHandler->setSource(m_source); - Qt3DCore::QEntity *sub = sceneIOHandler->scene(); - if (sub) { - sceneSubTree = sub; - break; + // 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; + + // File type is supported, try to load it + sceneIOHandler->setSource(m_source); + Qt3DCore::QEntity *sub = sceneIOHandler->scene(); + if (sub) { + sceneSubTree = sub; + break; + } } } - // 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 (scene && sceneSubTree) + + // If the sceneSubTree is null it will trigger the frontend to unload + // any subtree it may hold + if (scene) scene->setSceneSubtree(sceneSubTree); } |