diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-05-21 13:01:36 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-05-21 13:35:02 +0200 |
commit | 8cab87677a7ad61b63f778e945404c0bbe13e8c7 (patch) | |
tree | fff38043f6fd8cbfe803fffa1b1e0a99dbb1b33d /src/quick/items/qquickshadereffect.cpp | |
parent | b1e9bc580adc1e7b3b1398f392016880dc5201ba (diff) |
Avoid assertion when having a ShaderEffect as a delegate
The assertion occurred when it initially tried to create an item from the
delegate because it needed to show the contents of the first item when the
combobox was collapsed.
So, in order to do that ComboBox would create an object from the delegate
by calling delegateModel->object(). Since the ShaderEffect was not ready
to be constructed yet (it didn't have a window, see
QQuickOpenGLShaderEffect::maybeUpdateShaders() ) it would call polish on
itself in order to try later. Shortly after, it called
delegateModel->release(). This didn't delete the object immediately (it
called deleteLater() on the object), but it removed the engine and context
it was associated with).
However, this left it in the list of QQuickWindowPrivate::itemsToPolish.
Due to this, QQuickWindow would call updatePolish on it shortly after (as
a response to an expose event in our case). But the ShaderEffect was still
not associated with an engine, so it would ultimately assert with no
engine.
The fix is to simply check if the ShaderEffect has an engine, and return
early if that happens.
Then when the dropdown opens, the ShaderEffect will get a polish() because
of QQuickItemPrivate::recursiveRefFromEffectItem(), and it will have both
an engine and a window and will properly initialize its shaders.
Fixes: QTBUG-67343
Change-Id: Ib8ceb92d0fafb9b958407a50db5daa7b45e1d82a
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items/qquickshadereffect.cpp')
-rw-r--r-- | src/quick/items/qquickshadereffect.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index ab79b69c8c..78458ce6b0 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -864,6 +864,8 @@ QString QQuickShaderEffect::parseLog() // for OpenGL-based autotests void QQuickShaderEffectPrivate::updatePolish() { Q_Q(QQuickShaderEffect); + if (!qmlEngine(q)) + return; #if QT_CONFIG(opengl) if (q->m_glImpl) { q->m_glImpl->maybeUpdateShaders(); |