diff options
| author | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-08-24 23:32:24 +0200 |
|---|---|---|
| committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-09-10 17:36:30 +0200 |
| commit | 8b7db63290e12957a96cbfc9a935d44fc907981c (patch) | |
| tree | 5a1b0a3185c5e216face69b4efd275c5bded9456 /src/quick/util/qquickpixmapcache.cpp | |
| parent | fe6592fa7495c18e19bbefd360638d8d2944ce65 (diff) | |
Remove QQuickPixmapData::declarativePixmaps
On one hand, most private classes have q-pointers; but
- this list wasn't used for anything more than leak prevention
(since b99c9490c398fb4d285d5f28edd553445b76d79f)
- QQuickPixmapData is a bit more independent than a QObjectPrivate:
it has its own reference counting, and one instance can be the
PIMPL behind multiple QQuickPixmap instances
- we have other mechanisms for leak prevention now (release() in various
scenarios, prevUnreferenced/nextUnreferenced, purging
QQuickPixmapStore::m_cache at shutdown), so this looks redundant
- the longer-term owner of the QQuickPixmapData instances is
QQuickPixmapStore::m_cache
- QIntrusiveList is confusing and unusual
Change-Id: I1f427addb1f1a05b1efe156c9e9a102dcbb730b5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
| -rw-r--r-- | src/quick/util/qquickpixmapcache.cpp | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 46ecdf1928..c8fdf61797 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -312,7 +312,7 @@ public: , storeToCache(true) #endif { - declarativePixmaps.insert(pixmap); + Q_UNUSED(pixmap); } QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QRect &r, const QSize &s, const QQuickImageProviderOptions &po, @@ -326,7 +326,7 @@ public: , storeToCache(true) #endif { - declarativePixmaps.insert(pixmap); + Q_UNUSED(pixmap); } QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, QQuickTextureFactory *texture, @@ -341,7 +341,7 @@ public: , storeToCache(true) #endif { - declarativePixmaps.insert(pixmap); + Q_UNUSED(pixmap); } QQuickPixmapData(QQuickPixmap *pixmap, QQuickTextureFactory *texture) @@ -353,18 +353,13 @@ public: , storeToCache(true) #endif { + Q_UNUSED(pixmap); if (texture) requestSize = implicitSize = texture->textureSize(); - declarativePixmaps.insert(pixmap); } ~QQuickPixmapData() { - while (!declarativePixmaps.isEmpty()) { - QQuickPixmap *referencer = declarativePixmaps.first(); - declarativePixmaps.remove(referencer); - referencer->d = nullptr; - } delete textureFactory; } @@ -395,9 +390,6 @@ public: // actual image data, after loading QQuickTextureFactory *textureFactory; - // linked list of referencers, just to prevent memory leaks: see QQuickPixmapData dtor - QIntrusiveList<QQuickPixmap, &QQuickPixmap::dataListNode> declarativePixmaps; - QQuickPixmapReply *reply; // prev/next pointers to form a linked list for dereferencing pixmaps that are currently unused @@ -1675,7 +1667,6 @@ QQuickPixmap::QQuickPixmap(const QUrl &url, const QImage &image) QQuickPixmap::~QQuickPixmap() { if (d) { - d->declarativePixmaps.remove(this); d->release(); d = nullptr; } @@ -1801,7 +1792,6 @@ void QQuickPixmap::setPixmap(const QQuickPixmap &other) d->release(); d = other.d; d->addref(); - d->declarativePixmaps.insert(this); } } @@ -1854,7 +1844,6 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &reques qreal devicePixelRatio) { if (d) { - d->declarativePixmaps.remove(this); d->release(); d = nullptr; } @@ -1939,7 +1928,6 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &reques } else { d = *iter; d->addref(); - d->declarativePixmaps.insert(this); qCDebug(lcImg) << "loaded from cache" << url << "frame" << frame; } } @@ -1984,7 +1972,6 @@ void QQuickPixmap::loadImageFromDevice(QQmlEngine *engine, QIODevice *device, co } else { d = *iter; d->addref(); - d->declarativePixmaps.insert(this); qCDebug(lcImg) << "loaded from cache" << url << "frame" << frame << "refCount" << d->refCount; locker.unlock(); if (oldD) @@ -1995,7 +1982,6 @@ void QQuickPixmap::loadImageFromDevice(QQmlEngine *engine, QIODevice *device, co void QQuickPixmap::clear() { if (d) { - d->declarativePixmaps.remove(this); d->release(); d = nullptr; } @@ -2006,7 +1992,6 @@ void QQuickPixmap::clear(QObject *obj) if (d) { if (d->reply) QObject::disconnect(d->reply, nullptr, obj, nullptr); - d->declarativePixmaps.remove(this); d->release(); d = nullptr; } |
