From daee9af969a04a2919a948ba1f5d314626925a9a Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 25 Jan 2019 21:15:43 +0100 Subject: QtGui: mark obsolete QPixmapCache::find() functions as deprecated QPixmapCache::find(QString) and QPixmapCache::find(QString, QPixmap&) are deprecated since Qt4 times. Explicit mark them as deprecated so they can be removed with Qt6. Change-Id: Iaf185f69afe02203559a1c812fbb4a95c9049a1d Reviewed-by: Eirik Aavitsland --- src/gui/image/qicon.cpp | 6 +++--- src/gui/image/qpixmapcache.cpp | 12 ++++++++---- src/gui/image/qpixmapcache.h | 4 ++++ src/gui/painting/qbrush.cpp | 2 +- src/gui/painting/qpainter.cpp | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 285cdf790a..c3c4b24678 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -315,9 +315,9 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St % HexString(actualSize.height()); if (mode == QIcon::Active) { - if (QPixmapCache::find(key % HexString(mode), pm)) + if (QPixmapCache::find(key % HexString(mode), &pm)) return pm; // horray - if (QPixmapCache::find(key % HexString(QIcon::Normal), pm)) { + if (QPixmapCache::find(key % HexString(QIcon::Normal), &pm)) { QPixmap active = pm; if (QGuiApplication *guiApp = qobject_cast(qApp)) active = static_cast(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(QIcon::Active, pm); @@ -326,7 +326,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St } } - if (!QPixmapCache::find(key % HexString(mode), pm)) { + if (!QPixmapCache::find(key % HexString(mode), &pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 3d1652f68b..66907bebd7 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -469,10 +469,13 @@ QPixmapCacheEntry::~QPixmapCacheEntry() pm_cache()->releaseKey(key); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete \overload + Use bool find(const QString &, QPixmap *) instead. + Returns the pixmap associated with the \a key in the cache, or null if there is no such pixmap. @@ -494,13 +497,14 @@ QPixmap *QPixmapCache::find(const QString &key) /*! \obsolete - Use bool find(const QString&, QPixmap*) instead. + Use bool find(const QString &, QPixmap *) instead. */ -bool QPixmapCache::find(const QString &key, QPixmap& pixmap) +bool QPixmapCache::find(const QString &key, QPixmap &pixmap) { return find(key, &pixmap); } +#endif /*! Looks for a cached pixmap associated with the given \a key in the cache. @@ -513,7 +517,7 @@ bool QPixmapCache::find(const QString &key, QPixmap& pixmap) \snippet code/src_gui_image_qpixmapcache.cpp 1 */ -bool QPixmapCache::find(const QString &key, QPixmap* pixmap) +bool QPixmapCache::find(const QString &key, QPixmap *pixmap) { QPixmap *ptr = pm_cache()->object(key); if (ptr && pixmap) @@ -530,7 +534,7 @@ bool QPixmapCache::find(const QString &key, QPixmap* pixmap) \since 4.6 */ -bool QPixmapCache::find(const Key &key, QPixmap* pixmap) +bool QPixmapCache::find(const Key &key, QPixmap *pixmap) { //The key is not valid anymore, a flush happened before probably if (!key.d || !key.d->isValid) diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h index ea10ab1b76..12d05b00f3 100644 --- a/src/gui/image/qpixmapcache.h +++ b/src/gui/image/qpixmapcache.h @@ -76,8 +76,12 @@ public: static int cacheLimit(); static void setCacheLimit(int); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use bool find(const QString &, QPixmap *) instead") static QPixmap *find(const QString &key); + QT_DEPRECATED_X("Use bool find(const QString &, QPixmap *) instead") static bool find(const QString &key, QPixmap &pixmap); +#endif static bool find(const QString &key, QPixmap *pixmap); static bool find(const Key &key, QPixmap *pixmap); static bool insert(const QString &key, const QPixmap &pixmap); diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 860653cc4c..abfa8d41bb 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -111,7 +111,7 @@ Q_GUI_EXPORT QPixmap qt_pixmapForBrush(int brushStyle, bool invert) QString key = QLatin1String("$qt-brush$") % HexString(brushStyle) % QLatin1Char(invert ? '1' : '0'); - if (!QPixmapCache::find(key, pm)) { + if (!QPixmapCache::find(key, &pm)) { pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert), QImage::Format_MonoLSB); QPixmapCache::insert(key, pm); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index df2f5e11d3..6626768d51 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6210,7 +6210,7 @@ static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen) % HexString(pen.widthF()); QPixmap pixmap; - if (QPixmapCache::find(key, pixmap)) + if (QPixmapCache::find(key, &pixmap)) return pixmap; const qreal halfPeriod = qMax(qreal(2), qreal(radiusBase * 1.61803399)); // the golden ratio -- cgit v1.2.3