summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWieland Hagen <wieland.hagen@kdab.com>2017-01-01 21:09:46 +0700
committerWieland Hagen <wieland.hagen@kdab.com>2017-01-07 14:06:08 +0000
commitda566710685118dfce4919595ff6cb1d0ad61842 (patch)
tree8ebfe2226973a64a7bf434a7cfc47533674515eb
parent290dc3a180ca1023f18af4eb47911b16af82eb93 (diff)
Allow Qt3DWindow::setRootEntity() after window has been shown
Task-number: QTBUG-56403 Change-Id: Iea63ac7560c3f0cd20ee79ed92d47a77f9f6dcc2 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/extras/defaults/qt3dwindow.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/extras/defaults/qt3dwindow.cpp b/src/extras/defaults/qt3dwindow.cpp
index ab0b0e400..06ff14212 100644
--- a/src/extras/defaults/qt3dwindow.cpp
+++ b/src/extras/defaults/qt3dwindow.cpp
@@ -130,8 +130,13 @@ void Qt3DWindow::registerAspect(const QString &name)
void Qt3DWindow::setRootEntity(Qt3DCore::QEntity *root)
{
- Q_ASSERT(!isVisible());
- m_userRoot = root;
+ if (m_userRoot != root) {
+ if (m_userRoot != nullptr)
+ m_userRoot->setParent(static_cast<Qt3DCore::QNode*>(nullptr));
+ if (root != nullptr)
+ root->setParent(m_root);
+ m_userRoot = root;
+ }
}
void Qt3DWindow::setActiveFrameGraph(Qt3DRender::QFrameGraphNode *activeFrameGraph)
@@ -157,9 +162,6 @@ Qt3DRender::QCamera *Qt3DWindow::camera() const
void Qt3DWindow::showEvent(QShowEvent *e)
{
if (!m_initialized) {
- if (m_userRoot != nullptr)
- m_userRoot->setParent(m_root);
-
m_root->addComponent(m_renderSettings);
m_root->addComponent(m_inputSettings);
m_aspectEngine->setRootEntity(Qt3DCore::QEntityPtr(m_root));