From 2df56f182df3df54ae9bc8d75acf895e5f607592 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 17 Sep 2023 13:43:47 +0200 Subject: [PATCH] GRAPHICS: MACGUI: Wrap more relevant code into #ifdef USE_PNG --- graphics/macgui/mactext.cpp | 13 +++++++------ graphics/macgui/mactext.h | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 4dcaffe67fd..3ec6b6241b6 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -273,8 +273,10 @@ MacText::~MacText() { delete _cursorSurface; delete _cursorSurface2; +#ifdef USE_PNG for (auto &i : _imageCache) delete i._value; +#endif delete _imageArchive; } @@ -2793,6 +2795,11 @@ void MacText::setImageArchive(Common::String fname) { } const Surface *MacText::getImageSurface(Common::String &fname) { +#ifndef USE_PNG + warning("MacText::getImageSurface(): PNG support not compiled. Cannot load file %s", fname.c_str()); + + return nullptr; +#else if (_imageCache.contains(fname)) return _imageCache[fname]->getSurface(); @@ -2808,12 +2815,6 @@ const Surface *MacText::getImageSurface(Common::String &fname) { return nullptr; } -#ifndef USE_PNG - warning("MacText::getImageSurface(): PNG support not compiled. Cannot load file %s", fname.c_str()); - - return nullptr; -#else - _imageCache[fname] = new Image::PNGDecoder(); if (!_imageCache[fname]->loadStream(*stream)) { diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index 542aa9e880f..8ac847fecc2 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -395,7 +395,9 @@ private: MacMenu *_menu; +#ifdef USE_PNG Common::HashMap _imageCache; +#endif Common::Archive *_imageArchive = nullptr; };