From 0caffd37fb339402a9591d3a8dbad4f682f3e1e0 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 11 Sep 2020 15:58:20 +0200 Subject: [PATCH] Inline trivial function used only by deprecated functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QIcon had two methods calling a trivial local static; both were deprecated. Inlined the local static rather than #if-ing it on the same deprecation #if-ery. Shift the #if-ery on the deprecated methods to embrace also their docs. Change-Id: I5f6755ef99dd6b4abddc343c9bedf4815e50d567 Reviewed-by: Morten Johan Sørvig --- src/gui/image/qicon.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 826627359d..73b25fd584 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -124,19 +124,6 @@ static void qt_cleanup_icon_cache() qtIconCache()->clear(); } -/*! \internal - - Returns the effective device pixel ratio, using - the provided window pointer if possible. -*/ -static qreal qt_effective_device_pixel_ratio(QWindow *window = nullptr) -{ - if (window) - return window->devicePixelRatio(); - - return qApp->devicePixelRatio(); // Don't know which window to target. -} - QIconPrivate::QIconPrivate(QIconEngine *e) : engine(e), ref(1), serialNum(nextSerialNumCounter()), @@ -855,6 +842,7 @@ QPixmap QIcon::pixmap(const QSize &size, qreal devicePixelRatio, Mode mode, Stat return pixmap; } +#if QT_DEPRECATED_SINCE(6, 0) /*! \since 5.1 \deprecated @@ -871,13 +859,12 @@ QPixmap QIcon::pixmap(const QSize &size, qreal devicePixelRatio, Mode mode, Stat \sa actualSize(), paint() */ -#if QT_DEPRECATED_SINCE(6, 0) QPixmap QIcon::pixmap(QWindow *window, const QSize &size, Mode mode, State state) const { if (!d) return QPixmap(); - qreal devicePixelRatio = qt_effective_device_pixel_ratio(window); + qreal devicePixelRatio = window ? window->devicePixelRatio() : qApp->devicePixelRatio(); return pixmap(size, devicePixelRatio, mode, state); } #endif @@ -905,6 +892,7 @@ QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const return actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize); } +#if QT_DEPRECATED_SINCE(6, 0) /*! \since 5.1 @@ -917,13 +905,12 @@ QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const \sa actualSize(), pixmap(), paint() */ -#if QT_DEPRECATED_SINCE(6, 0) QSize QIcon::actualSize(QWindow *window, const QSize &size, Mode mode, State state) const { if (!d) return QSize(); - qreal devicePixelRatio = qt_effective_device_pixel_ratio(window); + qreal devicePixelRatio = window ? window->devicePixelRatio() : qApp->devicePixelRatio(); // Handle the simple normal-dpi case: if (!(devicePixelRatio > 1.0))