[Scummvm-git-logs] scummvm master -> 577322f3fe2b1e1006a60f6a6ab8d16a7410fc0d
criezy
criezy at scummvm.org
Wed Feb 17 12:57:27 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
577322f3fe GUI: Don't leak theme and TextDrawData when loading fails
Commit: 577322f3fe2b1e1006a60f6a6ab8d16a7410fc0d
https://github.com/scummvm/scummvm/commit/577322f3fe2b1e1006a60f6a6ab8d16a7410fc0d
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2021-02-17T12:57:23Z
Commit Message:
GUI: Don't leak theme and TextDrawData when loading fails
Changed paths:
gui/ThemeEngine.cpp
gui/gui-manager.cpp
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 14a62eb7ef..9f94b842ea 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -577,6 +577,11 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &language, const
ttsMan->setLanguage("en");
#endif // USE_TTS
#endif // USE_TRANSLATION
+
+ // No font, cleanup TextDrawData
+ delete _texts[textId];
+ _texts[textId] = nullptr;
+
return false; // fall-back attempt failed
}
// Success in fall-back attempt to standard (non-localized) font.
@@ -592,6 +597,10 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &language, const
#endif // USE_TRANSLATION
// Returning true here, would allow falling back to standard fonts for the missing ones,
// but that leads to "garbage" glyphs being displayed on screen for non-Latin languages
+ // No font, cleanup TextDrawData
+ delete _texts[textId];
+ _texts[textId] = nullptr;
+
return false;
}
}
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 751a72dc48..e7a8563b35 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -182,8 +182,10 @@ bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx,
newTheme = new ThemeEngine(id, gfx);
assert(newTheme);
- if (!newTheme->init())
+ if (!newTheme->init()) {
+ delete newTheme;
return false;
+ }
//
// Disable and delete the old theme
More information about the Scummvm-git-logs
mailing list