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:
parent
0f10af0f18
commit
04b4ae3ba8
1 changed files with 3 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue