fix: use QPointer for CachingImageManager::m_item

Raw QQuickItem* was not tracked for destruction, causing
use-after-free if the QML engine destroyed the item while
an async sha256 future was in flight.
This commit is contained in:
2 * r + 2 * t 2026-03-24 01:52:00 +11:00
parent 0f10af0f18
commit 04b4ae3ba8

View file

@ -2,6 +2,7 @@
#include <QtQuick/qquickitem.h>
#include <qobject.h>
#include <qpointer.h>
#include <qqmlintegration.h>
namespace caelestia::internal {
@ -18,8 +19,7 @@ class CachingImageManager : public QObject {
public:
explicit CachingImageManager(QObject* parent = nullptr)
: QObject(parent)
, m_item(nullptr) {}
: QObject(parent) {}
[[nodiscard]] QQuickItem* item() const;
void setItem(QQuickItem* item);
@ -46,7 +46,7 @@ signals:
private:
QString m_shaPath;
QQuickItem* m_item;
QPointer<QQuickItem> m_item;
QUrl m_cacheDir;
QString m_path;