From d4643a627b631a74cfaaa049dfd516cc734f367e Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 20 Jul 2022 12:21:52 +0200 Subject: [PATCH] App: Set QPixmapCache limit according to devicePixelRatio Higher resolution also means more data to be cached. The default 10MB cache limit don't cut it in HighDpi, especially in cache-intensive parts like the welcome screen. Change-Id: I653a939c3a37f80647d73e8de8df616d5386e39c Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot --- src/app/main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app/main.cpp b/src/app/main.cpp index 0ba1ea6a05a..8b7b8d62944 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -63,6 +63,7 @@ #include #include +#include #include #include #include @@ -294,6 +295,14 @@ static void setHighDpiEnvironmentVariable() } } +void setPixmapCacheLimit() +{ + const int originalLimit = QPixmapCache::cacheLimit(); + const qreal dpr = qApp->devicePixelRatio(); + const qreal multiplier = std::clamp(dpr * dpr, 1.0, 4.0); + QPixmapCache::setCacheLimit(originalLimit * multiplier); +} + void loadFonts() { const QDir dir(resourcePath() + "/fonts/"); @@ -562,6 +571,7 @@ int main(int argc, char **argv) QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR), QLatin1String(Core::Constants::IDE_CASED_ID)); Utils::TerminalCommand::setSettings(settings); + setPixmapCacheLimit(); loadFonts(); if (Utils::HostOsInfo::isWindowsHost()