From 315bce20fcb47eb4db2775147e4503d72403156c Mon Sep 17 00:00:00 2001 From: Ye ShanShan Date: Wed, 18 Sep 2024 14:07:02 +0800 Subject: [PATCH] fix: app crashed when InWindowBlur switching frequently Data maybe deleted in CleanJob, but RhiNode also have the invalide pointer by the texture variable. We use dataList whether contains the Data to judge it is valid. --- src/private/dbackdropnode.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/private/dbackdropnode.cpp b/src/private/dbackdropnode.cpp index 37183bbee..4f59fd464 100644 --- a/src/private/dbackdropnode.cpp +++ b/src/private/dbackdropnode.cpp @@ -157,17 +157,22 @@ class Q_DECL_HIDDEN DataManager : public DataManagerBase } } + bool isValidData(const Data *data) const { + return dataList.contains(data); + } + inline QQuickWindow *owner() const { return static_cast(parent()); } Data *resolve(Data *data, DataKeys&&... keys) { - if (data && get()->check(data->data, std::forward(keys)...) - && dataList.contains(data)) { - return data; + if (isValidData(data)) { + if (data && get()->check(data->data, std::forward(keys)...)) { + return data; + } + if (data) + release(data); } - if (data) - release(data); for (auto data : dataList) { if (get()->check(data->data, std::forward(keys)...)) { @@ -706,7 +711,7 @@ class Q_DECL_HIDDEN RhiNode : public DBackdropNode { if (oldManager != manager) { sgTexture()->setTexture(nullptr); - if (oldManager && texture) + if (oldManager && oldManager->isValidData(texture)) oldManager->release(texture); }