Browse Source

Setup pixmap cache in a proper place

There is no need to reset the cache limit to previous value as
QPixmapCache is an application wide cache.
Also raise the cache size to 64MB.
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
7e0daf1663
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 25
      src/app/application.cpp
  2. 18
      src/gui/torrentcontentmodel.cpp

25
src/app/application.cpp

@ -33,6 +33,10 @@
#include <algorithm> #include <algorithm>
#ifdef DISABLE_GUI
#include <cstdio>
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <memory> #include <memory>
#include <Windows.h> #include <Windows.h>
@ -47,6 +51,7 @@
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
#include <QMessageBox> #include <QMessageBox>
#include <QPixmapCache>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <QSessionManager> #include <QSessionManager>
#include <QSharedMemory> #include <QSharedMemory>
@ -54,14 +59,7 @@
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
#include <QFileOpenEvent> #include <QFileOpenEvent>
#endif // Q_OS_MAC #endif // Q_OS_MAC
#include "addnewtorrentdialog.h" #endif
#include "gui/uithememanager.h"
#include "gui/utils.h"
#include "mainwindow.h"
#include "shutdownconfirmdialog.h"
#else // DISABLE_GUI
#include <cstdio>
#endif // DISABLE_GUI
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
@ -85,6 +83,14 @@
#include "applicationinstancemanager.h" #include "applicationinstancemanager.h"
#include "filelogger.h" #include "filelogger.h"
#ifndef DISABLE_GUI
#include "addnewtorrentdialog.h"
#include "gui/uithememanager.h"
#include "gui/utils.h"
#include "mainwindow.h"
#include "shutdownconfirmdialog.h"
#endif // DISABLE_GUI
#ifndef DISABLE_WEBUI #ifndef DISABLE_WEBUI
#include "webui/webui.h" #include "webui/webui.h"
#endif #endif
@ -114,6 +120,8 @@ namespace
const int MIN_FILELOG_SIZE = 1024; // 1KiB const int MIN_FILELOG_SIZE = 1024; // 1KiB
const int MAX_FILELOG_SIZE = 1000 * 1024 * 1024; // 1000MiB const int MAX_FILELOG_SIZE = 1000 * 1024 * 1024; // 1000MiB
const int DEFAULT_FILELOG_SIZE = 65 * 1024; // 65KiB const int DEFAULT_FILELOG_SIZE = 65 * 1024; // 65KiB
const int PIXMAP_CACHE_SIZE = 64 * 1024 * 1024; // 64MiB
} }
Application::Application(const QString &id, int &argc, char **argv) Application::Application(const QString &id, int &argc, char **argv)
@ -131,6 +139,7 @@ Application::Application(const QString &id, int &argc, char **argv)
setDesktopFileName("org.qbittorrent.qBittorrent"); setDesktopFileName("org.qbittorrent.qBittorrent");
setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support
setQuitOnLastWindowClosed(false); setQuitOnLastWindowClosed(false);
QPixmapCache::setCacheLimit(PIXMAP_CACHE_SIZE);
#endif #endif
validateCommandLineParameters(); validateCommandLineParameters();

18
src/gui/torrentcontentmodel.cpp

@ -77,24 +77,6 @@ namespace
}; };
#ifdef QBT_PIXMAP_CACHE_FOR_FILE_ICONS #ifdef QBT_PIXMAP_CACHE_FOR_FILE_ICONS
struct Q_DECL_UNUSED PixmapCacheSetup
{
static const int PixmapCacheForIconsSize = 2 * 1024 * 1024; // 2 MiB for file icons
PixmapCacheSetup()
{
QPixmapCache::setCacheLimit(QPixmapCache::cacheLimit() + PixmapCacheForIconsSize);
}
~PixmapCacheSetup()
{
Q_ASSERT(QPixmapCache::cacheLimit() > PixmapCacheForIconsSize);
QPixmapCache::setCacheLimit(QPixmapCache::cacheLimit() - PixmapCacheForIconsSize);
}
};
PixmapCacheSetup pixmapCacheSetup;
class CachingFileIconProvider : public UnifiedFileIconProvider class CachingFileIconProvider : public UnifiedFileIconProvider
{ {
public: public:

Loading…
Cancel
Save