From 7705f290ca69c0478f698ddf06a5f1edb731e8fc Mon Sep 17 00:00:00 2001 From: flow Date: Tue, 15 Nov 2022 12:07:11 -0300 Subject: [PATCH] fix: don't retry to load RP images that can't fit in the cache Avoids an infinite loop when the image is too big. Signed-off-by: flow --- launcher/minecraft/mod/ResourcePack.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index 3fc10a2f..b97bedf8 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -47,6 +47,12 @@ void ResourcePack::setImage(QImage new_image) m_pack_image_cache_key.key = QPixmapCache::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)