From d8ab719c0890195cfce0fb6d4c76b3664d6f3a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 10 Mar 2020 11:13:59 +0100 Subject: Fix double scaling of SVG icons on high DPI screens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a high-dpi screen and AA_UseHighDpiPixmaps set, QIcon will ask its engine for a scaled-up pixmap. When the icon has been created from a theme, the engine is a QIconLoaderEngine. For a SVG icon, that engine would recursively use QIcon to load the scaled-up pixmap, leading to double scale-up. Fix by bypassing the QIcon API in the SVG case, loading the SVG icon directly from the SVG icon engine. Done-with: Tor Arne Vestbø Fixes: QTBUG-73587 Fixes: QTBUG-75039 Change-Id: I7fba02b6454decb5fcbca9c5a092e75954261dfd Reviewed-by: Eirik Aavitsland Reviewed-by: Tor Arne Vestbø --- src/gui/image/qiconloader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gui/image/qiconloader.cpp') diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 27c82bc09f..2f907a7709 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -797,8 +797,12 @@ QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State if (svgIcon.isNull()) svgIcon = QIcon(filename); - // Simply reuse svg icon engine - return svgIcon.pixmap(size, mode, state); + // Bypass QIcon API, as that will scale by device pixel ratio of the + // highest DPR screen since we're not passing on any QWindow. + if (QIconEngine *engine = svgIcon.data_ptr() ? svgIcon.data_ptr()->engine : nullptr) + return engine->pixmap(size, mode, state); + + return QPixmap(); } QPixmap QIconLoaderEngine::pixmap(const QSize &size, QIcon::Mode mode, -- cgit v1.2.3