diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-02-15 12:50:38 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-02-15 12:27:32 +0000 |
commit | 7454ad3ce1895eae7409df28752739cc912abcac (patch) | |
tree | 1a12200f12c223832a76247d586948ff248349d3 /src/quick/items/qquickopenglshadereffect.cpp | |
parent | 6a2cf39758249d790f642d677c7bc7cad2a70eae (diff) |
Shaders: Fix crash when disconnecting shaders from item properties
The disconnect was done with a signal index local to the item, instead
of 'global' to the item and all its parents. The index also had to be a
method index, not a signal index. Together this resulted in a failing
disconnect, which would keep SlotObjects alive with outdated data. Any
subsequent use would result in a crash.
Task-number: QTBUG-58336
Change-Id: I26b1868b2f8c61a4ffab1c72c85178632ca87599
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick/items/qquickopenglshadereffect.cpp')
-rw-r--r-- | src/quick/items/qquickopenglshadereffect.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp index b974641cca..c7b851d33e 100644 --- a/src/quick/items/qquickopenglshadereffect.cpp +++ b/src/quick/items/qquickopenglshadereffect.cpp @@ -256,10 +256,14 @@ void QQuickOpenGLShaderEffectCommon::connectPropertySignals(QQuickItem *item, qWarning("QQuickOpenGLShaderEffect: property '%s' does not have notification method!", d.name.constData()); } else { auto *mapper = signalMappers[shaderType].at(i); - mapper->setSignalIndex(pd->notifyIndex()); + mapper->setSignalIndex(itemMetaObject->property(d.propertyIndex).notifySignal().methodIndex()); Q_ASSERT(item->metaObject() == itemMetaObject); - QObjectPrivate::connectImpl(item, mapper->signalIndex(), item, nullptr, mapper, - Qt::AutoConnection, nullptr, itemMetaObject); + bool ok = QObjectPrivate::connectImpl(item, pd->notifyIndex(), item, nullptr, mapper, + Qt::AutoConnection, nullptr, itemMetaObject); + if (!ok) + qWarning() << "Failed to connect to property" << itemMetaObject->property(d.propertyIndex).name() + << "(" << d.propertyIndex << ", signal index" << pd->notifyIndex() + << ") of item" << item; } } else { // If the source is set via a dynamic property, like the layer is, then we need this |