[Scummvm-git-logs] scummvm master -> 034a5efe982744715230a3e22ed701af66f33cfe
rvanlaar
noreply at scummvm.org
Sat Sep 24 14:37:43 UTC 2022
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:
034a5efe98 DIRECTOR: Fix memory leak in registered FONDs
Commit: 034a5efe982744715230a3e22ed701af66f33cfe
https://github.com/scummvm/scummvm/commit/034a5efe982744715230a3e22ed701af66f33cfe
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-09-24T16:37:27+02:00
Commit Message:
DIRECTOR: Fix memory leak in registered FONDs
References to FOND resource streams are stored in an array.
Font streams were registered by their family name in a hashmap.
When a second font with the same name was encoutered it would replace
the pointer to the previous font.
The only use case for the hashmap was to register the stream to be able
to later close them.
Changed paths:
graphics/macgui/macfontmanager.cpp
graphics/macgui/macfontmanager.h
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index bac50287e57..cd1b159d9e8 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -186,7 +186,7 @@ MacFontManager::~MacFontManager() {
for (auto &it: _winFontRegistry)
delete it._value;
for (auto &it: _fontFamilies)
- delete it._value;
+ delete it;
}
void MacFontManager::setLocalizedFonts() {
@@ -427,7 +427,7 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
delete fond;
if (fontFamilyUsed)
- _fontFamilies[familyName] = fontFamily;
+ _fontFamilies.push_back(fontFamily);
else
delete fontFamily;
}
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index 92652abc8c0..f7ff03a2877 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -189,7 +189,7 @@ private:
Common::Language _language;
Common::HashMap<Common::String, Graphics::Font *> _winFontRegistry;
Common::HashMap<Common::String, MacFont *> _fontRegistry;
- Common::HashMap<Common::String, MacFontFamily *> _fontFamilies;
+ Common::Array<MacFontFamily *> _fontFamilies;
Common::HashMap<int, FontInfo *> _fontInfo;
Common::HashMap<Common::String, int> _fontIds;
More information about the Scummvm-git-logs
mailing list