diff options
author | Kaj Grönholm <[email protected]> | 2024-04-25 10:29:37 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2024-04-26 13:04:20 +0000 |
commit | ed4bd942e59b1fc156504cf0ee98647f3453c9fa (patch) | |
tree | def1be83a9d00c4a302daa70c0eb1a33cd915efb | |
parent | 708acd6d9161dbbde8a5a0409d54192a5ba639e4 (diff) |
Fix crash in MultiEffect with dynamic delegates
Changing dummy QQuickShaderEffectSource to be private variable rather
than static one fixes issue with dynamic delegates switching blurred
items on/off.
Fixes: QTBUG-124730
Change-Id: Ibaebfd6cb228fe1b7fa91c8219c1355a93ceb19c
Reviewed-by: Laszlo Agocs <[email protected]>
Reviewed-by: Tomi Korpipää <[email protected]>
Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
(cherry picked from commit 4375fff77441e11efc814a959950580d5b3645b5)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
(cherry picked from commit 0fde572310ac0c834d8b04a85afa150e6223ae75)
-rw-r--r-- | src/effects/qquickmultieffect.cpp | 5 | ||||
-rw-r--r-- | src/effects/qquickmultieffect_p_p.h | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/effects/qquickmultieffect.cpp b/src/effects/qquickmultieffect.cpp index 6b20c3fa14..7561649fbf 100644 --- a/src/effects/qquickmultieffect.cpp +++ b/src/effects/qquickmultieffect.cpp @@ -1697,11 +1697,12 @@ void QQuickMultiEffectPrivate::updateBlurItemsAmount(int blurLevel) } // Set the blur items source components - static const auto dummyShaderSource = new QQuickShaderEffectSource(q); + if (!m_dummyShaderSource) + m_dummyShaderSource = new QQuickShaderEffectSource(q); for (int i = 0; i < m_blurEffects.size(); i++) { auto *blurEffect = m_blurEffects[i]; auto sourceItem = (i >= itemsAmount) ? - static_cast<QQuickItem *>(dummyShaderSource) : (i == 0) ? + static_cast<QQuickItem *>(m_dummyShaderSource) : (i == 0) ? static_cast<QQuickItem *>(m_shaderSource->output()) : static_cast<QQuickItem *>(m_blurEffects[i - 1]); auto sourceVariant = QVariant::fromValue<QQuickItem*>(sourceItem); diff --git a/src/effects/qquickmultieffect_p_p.h b/src/effects/qquickmultieffect_p_p.h index 2df33db45b..7d635e2e25 100644 --- a/src/effects/qquickmultieffect_p_p.h +++ b/src/effects/qquickmultieffect_p_p.h @@ -27,6 +27,7 @@ QT_REQUIRE_CONFIG(quick_shadereffect); QT_BEGIN_NAMESPACE class QQuickShaderEffect; +class QQuickShaderEffectSource; class QQuickMultiEffectPrivate : public QQuickItemPrivate { @@ -145,6 +146,7 @@ private: QQuickItem *m_sourceItem = nullptr; QGfxSourceProxy *m_shaderSource = nullptr; QQuickShaderEffect *m_shaderEffect = nullptr; + QQuickShaderEffectSource *m_dummyShaderSource = nullptr; QVector<QQuickShaderEffect *> m_blurEffects; bool m_autoPaddingEnabled = true; QRectF m_paddingRect; |