From a852deda4d691fda51daedeeaa0a43eaeb101f82 Mon Sep 17 00:00:00 2001 From: RigoLigo Date: Tue, 22 Oct 2024 11:38:12 +0800 Subject: [PATCH] fix: StyledBehindWindowBlur crash in render thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如果StyledBehindWindowBlur位于Loader中,则在Loader变为非活动状态时,可能触发DQuickBehindWindowBlur渲染任务中引用已释放的对象导致程序崩溃。通过使用QPointer修复了这个问题:在m_item为非法时放弃渲染。 Log: --- src/private/dquickbehindwindowblur.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/private/dquickbehindwindowblur.cpp b/src/private/dquickbehindwindowblur.cpp index c5988c82b..097524508 100644 --- a/src/private/dquickbehindwindowblur.cpp +++ b/src/private/dquickbehindwindowblur.cpp @@ -32,7 +32,7 @@ class Q_DECL_HIDDEN DSGBlendNode : public QSGRenderNode } bool m_isRestore = false; - DQuickBehindWindowBlur *m_item = nullptr; + QPointer m_item = nullptr; QMatrix4x4 m_lastMatrix; QRegion m_lastClip; qreal m_lastRadius = -1; @@ -47,7 +47,10 @@ DSGBlendNode::DSGBlendNode(bool restore) void DSGBlendNode::render(const QSGRenderNode::RenderState *state) { - Q_ASSERT(m_item); + // m_item may become invalid when the referred blur behind item get destroyed by a Loader. + // Give up rendering in this case. + if (!m_item) + return; if (m_isRestore) return;