summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-02-18 07:42:35 +0000
committerPaul Lemire <paul.lemire@kdab.com>2020-02-18 07:55:58 +0000
commitc6fecd32f8dfe4d72a7f059f83d69e61d5ded64d (patch)
tree54aa42ff1bdf2e1d3d330cc7e5bf43cd82c86188 /src
parentecca6d21fbb4a07dcfe6144cc5a4f20981491bd1 (diff)
Revert "Allow for when a Scene3D item switches screens"
This reverts commit 648b7459e8a6ce8ce1f115a14da63d546b743439. Reason for revert: Introduces QTBUG-82275 Change-Id: I5514ad58707c086eaaab3203773614c939e461e8 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick3d/imports/scene3d/importsscene3d.pro2
-rw-r--r--src/quick3d/imports/scene3d/scene3dcleaner.cpp75
-rw-r--r--src/quick3d/imports/scene3d/scene3dcleaner_p.h82
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem.cpp114
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem_p.h10
-rw-r--r--src/quick3d/imports/scene3d/scene3drenderer.cpp44
-rw-r--r--src/quick3d/imports/scene3d/scene3drenderer_p.h15
7 files changed, 218 insertions, 124 deletions
diff --git a/src/quick3d/imports/scene3d/importsscene3d.pro b/src/quick3d/imports/scene3d/importsscene3d.pro
index c4c1b7cc8..e29f7b831 100644
--- a/src/quick3d/imports/scene3d/importsscene3d.pro
+++ b/src/quick3d/imports/scene3d/importsscene3d.pro
@@ -13,6 +13,7 @@ HEADERS += \
qtquickscene3dplugin.h \
scene3dlogging_p.h \
scene3ditem_p.h \
+ scene3dcleaner_p.h \
scene3drenderer_p.h \
scene3dsgnode_p.h \
scene3dsgmaterialshader_p.h \
@@ -23,6 +24,7 @@ SOURCES += \
qtquickscene3dplugin.cpp \
scene3ditem.cpp \
scene3dlogging.cpp \
+ scene3dcleaner.cpp \
scene3drenderer.cpp \
scene3dsgnode.cpp \
scene3dsgmaterialshader.cpp \
diff --git a/src/quick3d/imports/scene3d/scene3dcleaner.cpp b/src/quick3d/imports/scene3d/scene3dcleaner.cpp
new file mode 100644
index 000000000..ec371410d
--- /dev/null
+++ b/src/quick3d/imports/scene3d/scene3dcleaner.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "scene3dcleaner_p.h"
+
+#include <Qt3DCore/qaspectengine.h>
+#include <QtCore/qthread.h>
+
+#include <scene3dlogging_p.h>
+#include <scene3drenderer_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+Scene3DCleaner::Scene3DCleaner(QObject *parent)
+ : QObject(parent)
+ , m_renderer(nullptr)
+{
+}
+
+Scene3DCleaner::~Scene3DCleaner()
+{
+ qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
+}
+
+void Scene3DCleaner::cleanup()
+{
+ Q_ASSERT(m_renderer);
+ delete m_renderer->m_aspectEngine; // also deletes m_renderer->m_renderAspect
+ m_renderer->m_aspectEngine = nullptr;
+ m_renderer->m_renderAspect = nullptr;
+ m_renderer->deleteLater();
+ deleteLater();
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/quick3d/imports/scene3d/scene3dcleaner_p.h b/src/quick3d/imports/scene3d/scene3dcleaner_p.h
new file mode 100644
index 000000000..a246cbde7
--- /dev/null
+++ b/src/quick3d/imports/scene3d/scene3dcleaner_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_SCENE3DCLEANER_P_H
+#define QT3DRENDER_SCENE3DCLEANER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class Scene3DRenderer;
+
+class Scene3DCleaner : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Scene3DCleaner(QObject *parent = 0);
+ ~Scene3DCleaner();
+
+ void setRenderer(Scene3DRenderer *renderer) { m_renderer = renderer; }
+
+public Q_SLOTS:
+ void cleanup();
+
+private:
+ Scene3DRenderer *m_renderer;
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_SCENE3DCLEANER_H
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp
index 9a2caac89..f824d2c4e 100644
--- a/src/quick3d/imports/scene3d/scene3ditem.cpp
+++ b/src/quick3d/imports/scene3d/scene3ditem.cpp
@@ -68,6 +68,7 @@
#include <Qt3DRender/private/qrendersurfaceselector_p.h>
#include <Qt3DRender/private/qrenderaspect_p.h>
#include <Qt3DRender/private/rendersettings_p.h>
+#include <scene3dcleaner_p.h>
#include <scene3dlogging_p.h>
#include <scene3drenderer_p.h>
#include <scene3dsgnode_p.h>
@@ -149,8 +150,8 @@ Scene3DItem::Scene3DItem(QQuickItem *parent)
, m_viewHolderFG(nullptr)
, m_aspectEngine(new Qt3DCore::QAspectEngine())
, m_renderAspect(nullptr)
- , m_aspectToDelete(nullptr)
, m_renderer(nullptr)
+ , m_rendererCleaner(new Scene3DCleaner())
, m_multisample(true)
, m_dirty(true)
, m_dirtyViews(false)
@@ -178,8 +179,6 @@ Scene3DItem::~Scene3DItem()
// When the window is closed, it first destroys all of its children. At
// this point, Scene3DItem is destroyed but the Renderer, AspectEngine and
// Scene3DSGNode still exist and will perform their cleanup on their own.
- m_aspectEngine->deleteLater();
- m_renderer->deleteLater();
}
/*!
@@ -205,11 +204,18 @@ QStringList Scene3DItem::aspects() const
*/
Qt3DCore::QEntity *Scene3DItem::entity() const
{
- return m_entity.data();
+ return m_entity;
}
-void Scene3DItem::applyAspects()
+void Scene3DItem::setAspects(const QStringList &aspects)
{
+ if (!m_aspects.isEmpty()) {
+ qCWarning(Scene3D) << "Aspects already set on the Scene3D, ignoring";
+ return;
+ }
+
+ m_aspects = aspects;
+
// Aspects are owned by the aspect engine
for (const QString &aspect : qAsConst(m_aspects)) {
if (aspect == QLatin1String("render")) // This one is hardwired anyway
@@ -240,26 +246,16 @@ void Scene3DItem::applyAspects()
}
m_aspectEngine->registerAspect(aspect);
}
-}
-
-void Scene3DItem::setAspects(const QStringList &aspects)
-{
- if (!m_aspects.isEmpty()) {
- qWarning() << "Aspects already set on the Scene3D, ignoring";
- return;
- }
-
- m_aspects = aspects;
emit aspectsChanged();
}
void Scene3DItem::setEntity(Qt3DCore::QEntity *entity)
{
- if (entity == m_entity.data())
+ if (entity == m_entity)
return;
- m_entity.reset(entity);
+ m_entity = entity;
emit entityChanged();
}
@@ -402,21 +398,14 @@ void Scene3DItem::removeView(Scene3DView *view)
void Scene3DItem::applyRootEntityChange()
{
- if (m_aspectEngine->rootEntity() != m_entity.data()) {
- m_aspectEngine->setRootEntity(m_entity);
-
- /* If we changed window, the old aspect engine must be deleted only after we have set
- the root entity for the new one so that it doesn't delete the root node. */
- if (m_aspectToDelete) {
- delete m_aspectToDelete;
- m_aspectToDelete = nullptr;
- }
+ if (m_aspectEngine->rootEntity() != m_entity) {
+ m_aspectEngine->setRootEntity(Qt3DCore::QEntityPtr(m_entity));
// Set the render surface
if (!m_entity)
return;
- setWindowSurface(entity());
+ setWindowSurface(m_entity);
if (m_cameraAspectRatioMode == AutomaticAspectRatio) {
// Set aspect ratio of first camera to match the window
@@ -492,8 +481,6 @@ void Scene3DItem::onBeforeSync()
// if the Scene3D item is not visible
if (!isVisible() && dontRenderWhenHidden)
return;
- if (m_renderer->m_resetRequested)
- return;
Q_ASSERT(QThread::currentThread() == thread());
@@ -509,7 +496,7 @@ void Scene3DItem::onBeforeSync()
// Make renderer aware of any Scene3DView we are dealing with
if (m_dirtyViews) {
// Scene3DViews checks
- if (entity() != m_viewHolderEntity) {
+ if (m_entity != m_viewHolderEntity) {
qCWarning(Scene3D) << "Scene3DView is not supported if the Scene3D entity property has been set";
}
if (!usesFBO) {
@@ -557,48 +544,30 @@ void Scene3DItem::requestUpdate()
}
}
-void Scene3DItem::updateWindowSurface()
-{
- if (!m_entity || !m_dummySurface)
- return;
- Qt3DRender::QRenderSurfaceSelector *surfaceSelector =
- Qt3DRender::QRenderSurfaceSelectorPrivate::find(entity());
- if (surfaceSelector) {
- if (QWindow *rw = QQuickRenderControl::renderWindowFor(this->window())) {
- m_dummySurface->deleteLater();
- createDummySurface(rw, surfaceSelector);
- }
- }
-}
-
void Scene3DItem::setWindowSurface(QObject *rootObject)
{
Qt3DRender::QRenderSurfaceSelector *surfaceSelector = Qt3DRender::QRenderSurfaceSelectorPrivate::find(rootObject);
+
// Set the item's window surface if it appears
// the surface wasn't set on the surfaceSelector
if (surfaceSelector && !surfaceSelector->surface()) {
// We may not have a real, exposed QQuickWindow when the Quick rendering
// is redirected via QQuickRenderControl (f.ex. QQuickWidget).
if (QWindow *rw = QQuickRenderControl::renderWindowFor(this->window())) {
- createDummySurface(rw, surfaceSelector);
+ // rw is the top-level window that is backed by a native window. Do
+ // not use that though since we must not clash with e.g. the widget
+ // backingstore compositor in the gui thread.
+ m_dummySurface = new QOffscreenSurface;
+ m_dummySurface->setParent(qGuiApp); // parent to something suitably long-living
+ m_dummySurface->setFormat(rw->format());
+ m_dummySurface->setScreen(rw->screen());
+ m_dummySurface->create();
+ surfaceSelector->setSurface(m_dummySurface);
} else {
surfaceSelector->setSurface(this->window());
}
}
}
-
-void Scene3DItem::createDummySurface(QWindow *rw, Qt3DRender::QRenderSurfaceSelector *surfaceSelector)
-{
- // rw is the top-level window that is backed by a native window. Do
- // not use that though since we must not clash with e.g. the widget
- // backingstore compositor in the gui thread.
- m_dummySurface = new QOffscreenSurface;
- m_dummySurface->setParent(qGuiApp); // parent to something suitably long-living
- m_dummySurface->setFormat(rw->format());
- m_dummySurface->setScreen(rw->screen());
- m_dummySurface->create();
- surfaceSelector->setSurface(m_dummySurface);
-}
/*!
\qmlmethod void Scene3D::setItemAreaAndDevicePixelRatio(size area, real devicePixelRatio)
@@ -606,8 +575,7 @@ void Scene3DItem::createDummySurface(QWindow *rw, Qt3DRender::QRenderSurfaceSele
*/
void Scene3DItem::setItemAreaAndDevicePixelRatio(QSize area, qreal devicePixelRatio)
{
- Qt3DRender::QRenderSurfaceSelector *surfaceSelector
- = Qt3DRender::QRenderSurfaceSelectorPrivate::find(entity());
+ Qt3DRender::QRenderSurfaceSelector *surfaceSelector = Qt3DRender::QRenderSurfaceSelectorPrivate::find(m_entity);
if (surfaceSelector) {
surfaceSelector->setExternalRenderTargetSize(area);
surfaceSelector->setSurfacePixelRatio(devicePixelRatio);
@@ -697,16 +665,6 @@ void Scene3DItem::setMultisample(bool enable)
QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *)
{
- // m_resetRequested is set to true by Scene3DRenderer::shutdown()
- if (m_renderer && m_renderer->m_resetRequested) {
- QObject::disconnect(m_windowConnection);
- m_renderAspect = nullptr;
- m_aspectToDelete = m_aspectEngine;
- m_aspectEngine = new Qt3DCore::QAspectEngine();
- m_aspectEngine->setRunMode(Qt3DCore::QAspectEngine::Manual);
- applyAspects();
- m_renderer->m_resetRequested = false;
- }
// If the render aspect wasn't created yet, do so now
if (m_renderAspect == nullptr) {
m_renderAspect = new QRenderAspect(QRenderAspect::Synchronous);
@@ -717,24 +675,16 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode
// Before Synchronizing is in the SG Thread, we want beforeSync to be triggered
// in the context of the main thread
- m_windowConnection = QObject::connect(window(), &QQuickWindow::afterAnimating,
- this, &Scene3DItem::onBeforeSync, Qt::DirectConnection);
+ QObject::connect(window(), &QQuickWindow::afterAnimating,
+ this, &Scene3DItem::onBeforeSync, Qt::DirectConnection);
auto renderAspectPriv = static_cast<QRenderAspectPrivate*>(QRenderAspectPrivate::get(m_renderAspect));
QObject::connect(renderAspectPriv->m_aspectManager->changeArbiter(), &Qt3DCore::QChangeArbiter::receivedChange,
this, [this] { m_dirty = true; }, Qt::DirectConnection);
}
if (m_renderer == nullptr) {
- m_renderer = new Scene3DRenderer();
- m_renderer->init(this, m_aspectEngine, m_renderAspect);
- } else if (m_renderer->renderAspect() != m_renderAspect) {
- // If the renderer's renderAspect is not equal to the aspect used
- // by the item, then it means that we have created a new one due to
- // the fact that shutdown() was called on the renderer previously.
- // This is a typical situation when the window the item is in has
- // moved from one screen to another.
- updateWindowSurface();
- m_renderer->init(this, m_aspectEngine, m_renderAspect);
+ m_renderer = new Scene3DRenderer(this, m_aspectEngine, m_renderAspect);
+ m_renderer->setCleanerHelper(m_rendererCleaner);
}
const bool usesFBO = m_compositingMode == FBO;
const bool hasScene3DViews = !m_views.empty();
diff --git a/src/quick3d/imports/scene3d/scene3ditem_p.h b/src/quick3d/imports/scene3d/scene3ditem_p.h
index 0beaf94c0..e46bb20af 100644
--- a/src/quick3d/imports/scene3d/scene3ditem_p.h
+++ b/src/quick3d/imports/scene3d/scene3ditem_p.h
@@ -71,7 +71,6 @@ class Scene3DRenderer;
class Scene3DCleaner;
class Scene3DView;
class QFrameGraphNode;
-class QRenderSurfaceSelector;
class Scene3DItem : public QQuickItem
{
@@ -139,20 +138,16 @@ private:
void updateCameraAspectRatio();
void mousePressEvent(QMouseEvent *event) override;
bool needsRender();
- void updateWindowSurface();
- void createDummySurface(QWindow *window, QRenderSurfaceSelector *surfaceSelector);
- void applyAspects();
QStringList m_aspects;
- // Store as shared pointer so that aspect engine doesn't delete it.
- QSharedPointer<Qt3DCore::QEntity> m_entity;
+ Qt3DCore::QEntity *m_entity;
Qt3DCore::QEntity *m_viewHolderEntity;
Qt3DRender::QFrameGraphNode *m_viewHolderFG;
Qt3DCore::QAspectEngine *m_aspectEngine;
- Qt3DCore::QAspectEngine *m_aspectToDelete;
QRenderAspect *m_renderAspect;
Scene3DRenderer *m_renderer;
+ Scene3DCleaner *m_rendererCleaner;
bool m_multisample;
bool m_dirty;
@@ -165,7 +160,6 @@ private:
CompositingMode m_compositingMode;
QOffscreenSurface *m_dummySurface;
QVector<Scene3DView *> m_views;
- QMetaObject::Connection m_windowConnection;
};
} // Qt3DRender
diff --git a/src/quick3d/imports/scene3d/scene3drenderer.cpp b/src/quick3d/imports/scene3d/scene3drenderer.cpp
index 811a2aa29..fafeeedf4 100644
--- a/src/quick3d/imports/scene3d/scene3drenderer.cpp
+++ b/src/quick3d/imports/scene3d/scene3drenderer.cpp
@@ -53,6 +53,7 @@
#include <Qt3DCore/private/qchangearbiter_p.h>
#include <Qt3DCore/private/qservicelocator_p.h>
+#include <scene3dcleaner_p.h>
#include <scene3ditem_p.h>
#include <scene3dlogging_p.h>
#include <scene3dsgnode_p.h>
@@ -143,15 +144,16 @@ private:
signal of the window is not called. Therefore the cleanup method is invoked
to properly destroy the aspect engine.
*/
-Scene3DRenderer::Scene3DRenderer()
+Scene3DRenderer::Scene3DRenderer(Scene3DItem *item, Qt3DCore::QAspectEngine *aspectEngine, QRenderAspect *renderAspect)
: QObject()
- , m_item(nullptr)
- , m_aspectEngine(nullptr)
- , m_renderAspect(nullptr)
+ , m_item(item)
+ , m_aspectEngine(aspectEngine)
+ , m_renderAspect(renderAspect)
, m_multisampledFBO(nullptr)
, m_finalFBO(nullptr)
, m_texture(nullptr)
, m_node(nullptr)
+ , m_cleaner(nullptr)
, m_window(nullptr)
, m_multisample(false) // this value is not used, will be synced from the Scene3DItem instead
, m_lastMultisample(false)
@@ -163,17 +165,6 @@ Scene3DRenderer::Scene3DRenderer()
, m_allowRendering(0)
, m_compositingMode(Scene3DItem::FBO)
{
-}
-
-void Scene3DRenderer::init(Scene3DItem *item, Qt3DCore::QAspectEngine *aspectEngine,
- QRenderAspect *renderAspect)
-{
- m_item = item;
- m_window = m_item->window();
- m_aspectEngine = aspectEngine;
- m_renderAspect = renderAspect;
- m_needsShutdown = true;
-
Q_CHECK_PTR(m_item);
Q_CHECK_PTR(m_item->window());
@@ -224,14 +215,21 @@ void Scene3DRenderer::scheduleRootEntityChange()
QMetaObject::invokeMethod(m_item, "applyRootEntityChange", Qt::QueuedConnection);
}
+void Scene3DRenderer::setCleanerHelper(Scene3DCleaner *cleaner)
+{
+ m_cleaner = cleaner;
+ if (m_cleaner) {
+ // Window closed case
+ QObject::connect(m_item->window(), &QQuickWindow::destroyed, m_cleaner, &Scene3DCleaner::cleanup);
+ m_cleaner->setRenderer(this);
+ }
+}
+
// Executed in the QtQuick render thread (which may even be the gui/main with QQuickWidget / RenderControl).
void Scene3DRenderer::shutdown()
{
qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
- // In case the same item is rendered on another window reset it
- m_resetRequested = true;
-
// Set to null so that subsequent calls to render
// would return early
m_item = nullptr;
@@ -245,14 +243,8 @@ void Scene3DRenderer::shutdown()
// Shutdown the Renderer Aspect while the OpenGL context
// is still valid
- if (m_renderAspect) {
+ if (m_renderAspect)
static_cast<QRenderAspectPrivate*>(QRenderAspectPrivate::get(m_renderAspect))->renderShutdown();
- m_aspectEngine->unregisterAspect(m_renderAspect); // deletes render aspect
- m_renderAspect = nullptr;
- }
- m_aspectEngine = nullptr;
- m_finalFBO.reset();
- m_multisampledFBO.reset();
}
// QtQuick render thread (which may also be the gui/main thread with QQuickWidget / RenderControl)
@@ -262,6 +254,7 @@ void Scene3DRenderer::onSceneGraphInvalidated()
if (m_needsShutdown) {
m_needsShutdown = false;
shutdown();
+ QMetaObject::invokeMethod(m_cleaner, "cleanup");
}
}
@@ -272,6 +265,7 @@ void Scene3DRenderer::onWindowChanged(QQuickWindow *w)
if (m_needsShutdown) {
m_needsShutdown = false;
shutdown();
+ QMetaObject::invokeMethod(m_cleaner, "cleanup");
}
}
}
diff --git a/src/quick3d/imports/scene3d/scene3drenderer_p.h b/src/quick3d/imports/scene3d/scene3drenderer_p.h
index 5674f21c2..08a2c60a3 100644
--- a/src/quick3d/imports/scene3d/scene3drenderer_p.h
+++ b/src/quick3d/imports/scene3d/scene3drenderer_p.h
@@ -78,7 +78,9 @@ class Scene3DRenderer : public QObject
{
Q_OBJECT
public:
- Scene3DRenderer();
+ Scene3DRenderer(Scene3DItem *item,
+ Qt3DCore::QAspectEngine *aspectEngine,
+ QRenderAspect *renderAspect);
~Scene3DRenderer();
void setSGNode(Scene3DSGNode *node);
@@ -87,12 +89,7 @@ public:
void setCompositingMode(Scene3DItem::CompositingMode mode);
void setSkipFrame(bool skip);
void setScene3DViews(const QVector<Scene3DView *> views);
- void init(Scene3DItem *item, Qt3DCore::QAspectEngine *aspectEngine, QRenderAspect *renderAspect);
- QRenderAspect *renderAspect() const
- {
- return m_renderAspect;
- }
public Q_SLOTS:
void render();
void shutdown();
@@ -106,12 +103,13 @@ private:
void scheduleRootEntityChange();
Scene3DItem *m_item; // Will be released by the QQuickWindow/QML Engine
- Qt3DCore::QAspectEngine *m_aspectEngine; // Will be released by the Scene3DItem
+ Qt3DCore::QAspectEngine *m_aspectEngine; // Will be released by the Scene3DRendererCleaner
QRenderAspect *m_renderAspect; // Will be released by the aspectEngine
QScopedPointer<QOpenGLFramebufferObject> m_multisampledFBO;
QScopedPointer<QOpenGLFramebufferObject> m_finalFBO;
QScopedPointer<QSGTexture> m_texture;
Scene3DSGNode *m_node; // Will be released by the QtQuick SceneGraph
+ Scene3DCleaner *m_cleaner;
QQuickWindow *m_window;
QMutex m_windowMutex;
QSize m_lastSize;
@@ -125,9 +123,8 @@ private:
QSemaphore m_allowRendering;
Scene3DItem::CompositingMode m_compositingMode;
QVector<Scene3DView *> m_views;
- bool m_resetRequested = false;
- friend class Scene3DItem;
+ friend class Scene3DCleaner;
};
} // namespace Qt3DRender