diff options
Diffstat (limited to 'src/datavisualizationqml2/declarativerendernode.cpp')
-rw-r--r-- | src/datavisualizationqml2/declarativerendernode.cpp | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/datavisualizationqml2/declarativerendernode.cpp b/src/datavisualizationqml2/declarativerendernode.cpp index f61899e5..9ce25bf6 100644 --- a/src/datavisualizationqml2/declarativerendernode.cpp +++ b/src/datavisualizationqml2/declarativerendernode.cpp @@ -1,28 +1,33 @@ -/**************************************************************************** +/****************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd -** All rights reserved. -** For any questions to The Qt Company, please use contact form at http://qt.io +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Data Visualization module. ** -** Licensees holding valid commercial license for Qt may use this file in -** accordance with the Qt License Agreement provided with the Software -** or, alternatively, in accordance with the terms contained in a written -** agreement between you and The Qt Company. +** $QT_BEGIN_LICENSE:COMM$ ** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.io +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** -****************************************************************************/ +** $QT_END_LICENSE$ +** +******************************************************************************/ #include "declarativerendernode_p.h" #include "abstractdeclarative_p.h" #include <QtGui/QOpenGLFramebufferObject> +#include <QtCore/QMutexLocker> QT_BEGIN_NAMESPACE_DATAVISUALIZATION -DeclarativeRenderNode::DeclarativeRenderNode(AbstractDeclarative *declarative) +DeclarativeRenderNode::DeclarativeRenderNode(AbstractDeclarative *declarative, + const QSharedPointer<QMutex> &nodeMutex) : QSGGeometryNode(), m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4), m_texture(0), @@ -34,6 +39,7 @@ DeclarativeRenderNode::DeclarativeRenderNode(AbstractDeclarative *declarative) m_samples(0), m_dirtyFBO(false) { + m_nodeMutex = nodeMutex; setMaterial(&m_material); setOpaqueMaterial(&m_materialO); setGeometry(&m_geometry); @@ -45,6 +51,8 @@ DeclarativeRenderNode::~DeclarativeRenderNode() delete m_fbo; delete m_multisampledFBO; delete m_texture; + + m_nodeMutex.clear(); } void DeclarativeRenderNode::setSize(const QSize &size) @@ -113,7 +121,12 @@ void DeclarativeRenderNode::setQuickWindow(QQuickWindow *window) void DeclarativeRenderNode::setController(Abstract3DController *controller) { + QMutexLocker locker(m_nodeMutex.data()); m_controller = controller; + if (m_controller) { + connect(m_controller, &QObject::destroyed, + this, &DeclarativeRenderNode::handleControllerDestroyed, Qt::DirectConnection); + } } void DeclarativeRenderNode::setSamples(int samples) @@ -127,6 +140,11 @@ void DeclarativeRenderNode::setSamples(int samples) void DeclarativeRenderNode::preprocess() { + QMutexLocker locker(m_nodeMutex.data()); + + if (!m_controller) + return; + QOpenGLFramebufferObject *targetFBO; if (m_samples > 0) targetFBO = m_multisampledFBO; @@ -147,4 +165,10 @@ void DeclarativeRenderNode::preprocess() m_declarative->doneOpenGLContext(m_window); } +// This function is called within m_nodeMutex lock +void DeclarativeRenderNode::handleControllerDestroyed() +{ + m_controller = 0; +} + QT_END_NAMESPACE_DATAVISUALIZATION |