aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-12-11 04:16:21 -0800
committerGitHub <noreply@github.com>2022-12-11 04:16:21 -0800
commit5622bcc5632a0706634da1ab519a3346a018b159 (patch)
treec0bcd17c16c76945cde3d9a05519b4edbb66730f /launcher/minecraft
parent4a13d72997d4ed4d7f0df72c80c6e0aaabfea1e0 (diff)
parentc4c1e75de8825a4af403046536a7b2acd72a56c3 (diff)
downloadPrismLauncher-5622bcc5632a0706634da1ab519a3346a018b159.tar.gz
PrismLauncher-5622bcc5632a0706634da1ab519a3346a018b159.tar.bz2
PrismLauncher-5622bcc5632a0706634da1ab519a3346a018b159.zip
Merge pull request #461 from flowln/fix_big_resource_pack_imgs
Fixes https://github.com/PrismLauncher/PrismLauncher/issues/360
Diffstat (limited to 'launcher/minecraft')
-rw-r--r--launcher/minecraft/mod/ResourcePack.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp
index 4a9ad21b..3a2fd771 100644
--- a/launcher/minecraft/mod/ResourcePack.cpp
+++ b/launcher/minecraft/mod/ResourcePack.cpp
@@ -1,9 +1,11 @@
#include "ResourcePack.h"
+#include <QCoreApplication>
#include <QDebug>
#include <QMap>
#include <QRegularExpression>
+#include "MTPixmapCache.h"
#include "Version.h"
#include "minecraft/mod/tasks/LocalResourcePackParseTask.h"
@@ -43,16 +45,22 @@ void ResourcePack::setImage(QImage new_image)
Q_ASSERT(!new_image.isNull());
if (m_pack_image_cache_key.key.isValid())
- QPixmapCache::remove(m_pack_image_cache_key.key);
+ PixmapCache::instance().remove(m_pack_image_cache_key.key);
- m_pack_image_cache_key.key = QPixmapCache::insert(QPixmap::fromImage(new_image));
+ m_pack_image_cache_key.key = PixmapCache::instance().insert(QPixmap::fromImage(new_image));
m_pack_image_cache_key.was_ever_used = true;
+
+ // This can happen if the pixmap is too big to fit in the cache :c
+ if (!m_pack_image_cache_key.key.isValid()) {
+ qWarning() << "Could not insert a image cache entry! Ignoring it.";
+ m_pack_image_cache_key.was_ever_used = false;
+ }
}
QPixmap ResourcePack::image(QSize size)
{
QPixmap cached_image;
- if (QPixmapCache::find(m_pack_image_cache_key.key, &cached_image)) {
+ if (PixmapCache::instance().find(m_pack_image_cache_key.key, &cached_image)) {
if (size.isNull())
return cached_image;
return cached_image.scaled(size);