aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickshadereffectsource.cpp
diff options
context:
space:
mode:
authorTasuku Suzuki <stasuku@gmail.com>2014-09-11 12:31:18 +0900
committerTasuku Suzuki <stasuku@gmail.com>2014-09-12 01:16:46 +0200
commit97594aa3d82618c64f57e96116f39a59ab3bb029 (patch)
tree7db50c4e46b55689fab1327fc3ddbb2350550b24 /src/quick/items/qquickshadereffectsource.cpp
parent26aed3d930ef96ed214ccaf18a234ef3cb8730e4 (diff)
prevent crash when set ShaderEffectSource::sourceItem null
Regression introduced in 81ba77d736f07efac37d284cd741d71f9dad4149 Task-number: QTBUG-41241 Change-Id: I9a65af6915325e1cbf9205c7da94273d5b91b310 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/items/qquickshadereffectsource.cpp')
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp
index 80be283443..120a8956eb 100644
--- a/src/quick/items/qquickshadereffectsource.cpp
+++ b/src/quick/items/qquickshadereffectsource.cpp
@@ -322,24 +322,24 @@ void QQuickShaderEffectSource::setSourceItem(QQuickItem *item)
d->derefWindow();
}
- if (window() == item->window()) {
- m_sourceItem = item;
- } else {
- qWarning("ShaderEffectSource: sourceItem and ShaderEffectSource must both be children of the same window.");
- m_sourceItem = 0;
- }
+ m_sourceItem = item;
if (m_sourceItem) {
- QQuickItemPrivate *d = QQuickItemPrivate::get(item);
- // 'item' needs a window to get a scene graph node. It usually gets one through its
- // parent, but if the source item is "inline" rather than a reference -- i.e.
- // "sourceItem: Item { }" instead of "sourceItem: foo" -- it will not get a parent.
- // In those cases, 'item' should get the window from 'this'.
- if (window())
- d->refWindow(window());
- d->refFromEffectItem(m_hideSource);
- d->addItemChangeListener(this, QQuickItemPrivate::Geometry);
- connect(m_sourceItem, SIGNAL(destroyed(QObject*)), this, SLOT(sourceItemDestroyed(QObject*)));
+ if (window() == m_sourceItem->window()) {
+ QQuickItemPrivate *d = QQuickItemPrivate::get(item);
+ // 'item' needs a window to get a scene graph node. It usually gets one through its
+ // parent, but if the source item is "inline" rather than a reference -- i.e.
+ // "sourceItem: Item { }" instead of "sourceItem: foo" -- it will not get a parent.
+ // In those cases, 'item' should get the window from 'this'.
+ if (window())
+ d->refWindow(window());
+ d->refFromEffectItem(m_hideSource);
+ d->addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ connect(m_sourceItem, SIGNAL(destroyed(QObject*)), this, SLOT(sourceItemDestroyed(QObject*)));
+ } else {
+ qWarning("ShaderEffectSource: sourceItem and ShaderEffectSource must both be children of the same window.");
+ m_sourceItem = 0;
+ }
}
update();
emit sourceItemChanged();