aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorValery Volgutov <valery.volgutov@lge.com>2017-12-12 15:02:16 +0300
committerDominik Holland <dominik.holland@qt.io>2020-06-08 16:05:40 +0200
commit4e001269f0edd0c5ce94b522704f3c18e8a4dfab (patch)
tree555f14ff231f8036cc803ea0733219fd2bd29a6b /src/quick
parent316a120f37982db9f3062ac1e094d92da4e356d7 (diff)
Fix for possible crash in QSGDefaultLayer::grab
When QQuickItem::setParentItem set to NULL, derefWindow can be called. And for it item QSGNode will be destroyed. If this item used for QQuickEffectShaderSource we will have access to invalid QSGNode when "live" flag is enabled. Change-Id: If785e5328a044ec9d2564a82361470f1b8091fc5 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 1c5de027d0c31d1d6697bd0557128d92207763d8)
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp8
-rw-r--r--src/quick/items/qquickshadereffectsource_p.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp
index b298ed74da..4f61d61309 100644
--- a/src/quick/items/qquickshadereffectsource.cpp
+++ b/src/quick/items/qquickshadereffectsource.cpp
@@ -344,6 +344,7 @@ void QQuickShaderEffectSource::setSourceItem(QQuickItem *item)
d->refFromEffectItem(m_hideSource);
d->addItemChangeListener(this, QQuickItemPrivate::Geometry);
connect(m_sourceItem, SIGNAL(destroyed(QObject*)), this, SLOT(sourceItemDestroyed(QObject*)));
+ connect(m_sourceItem, SIGNAL(parentChanged(QQuickItem*)), this, SLOT(sourceItemParentChanged(QQuickItem*)));
} else {
qWarning("ShaderEffectSource: sourceItem and ShaderEffectSource must both be children of the same window.");
m_sourceItem = nullptr;
@@ -363,6 +364,13 @@ void QQuickShaderEffectSource::sourceItemDestroyed(QObject *item)
}
+void QQuickShaderEffectSource::sourceItemParentChanged(QQuickItem *parent)
+{
+ if (!parent && m_texture)
+ m_texture->setItem(0);
+}
+
+
/*!
\qmlproperty rect QtQuick::ShaderEffectSource::sourceRect
diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h
index c0a1ccab78..4deb6c70a3 100644
--- a/src/quick/items/qquickshadereffectsource_p.h
+++ b/src/quick/items/qquickshadereffectsource_p.h
@@ -173,6 +173,7 @@ Q_SIGNALS:
private Q_SLOTS:
void sourceItemDestroyed(QObject *item);
void invalidateSceneGraph();
+ void sourceItemParentChanged(QQuickItem *parent);
protected:
void releaseResources() override;