[Scummvm-cvs-logs] scummvm master -> b96143c1802b619553e476ad7a5a1eedeea0c768
lordhoto
lordhoto at gmail.com
Thu May 3 22:46:00 CEST 2012
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6bff611605 BASE: Destroy singletons on exit.
fdee01bf04 GRAPHICS: Don't try to delete static BDF data.
6d3927cd7a GRAPHICS: Take ownership of fonts passed to FontManager.
b470c9af28 BASE: Free TTFLibrary singleton on shutdown.
29e05ec05e OPENGL: Don't leak surfaces.
b96143c180 Merge pull request #213 from fuzzie/leak-fixes
Commit: 6bff6116050a892247f9d84a78e21922823bfc47
https://github.com/scummvm/scummvm/commit/6bff6116050a892247f9d84a78e21922823bfc47
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2012-03-28T10:16:29-07:00
Commit Message:
BASE: Destroy singletons on exit.
Changed paths:
base/main.cpp
diff --git a/base/main.cpp b/base/main.cpp
index 99dcac6..6fb56b4 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -55,6 +55,9 @@
#include "audio/mididrv.h"
#include "audio/musicplugin.h" /* for music manager */
+#include "graphics/cursorman.h"
+#include "graphics/fontman.h"
+
#include "backends/keymapper/keymapper.h"
#if defined(_WIN32_WCE)
@@ -493,10 +496,15 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
PluginManager::destroy();
GUI::GuiManager::destroy();
Common::ConfigManager::destroy();
+ Common::DebugManager::destroy();
+ Common::EventRecorder::destroy();
Common::SearchManager::destroy();
#ifdef USE_TRANSLATION
Common::TranslationManager::destroy();
#endif
+ MusicManager::destroy();
+ Graphics::CursorManager::destroy();
+ Graphics::FontManager::destroy();
return 0;
}
Commit: fdee01bf04f1d66e4365e39c871c4b00d7b78946
https://github.com/scummvm/scummvm/commit/fdee01bf04f1d66e4365e39c871c4b00d7b78946
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2012-03-28T10:16:52-07:00
Commit Message:
GRAPHICS: Don't try to delete static BDF data.
Changed paths:
graphics/fonts/bdf.h
diff --git a/graphics/fonts/bdf.h b/graphics/fonts/bdf.h
index 5b615cc..b0166a2 100644
--- a/graphics/fonts/bdf.h
+++ b/graphics/fonts/bdf.h
@@ -77,7 +77,7 @@ private:
#define DEFINE_FONT(n) \
const BdfFont *n = 0; \
void create_##n() { \
- n = new BdfFont(desc, DisposeAfterUse::YES); \
+ n = new BdfFont(desc, DisposeAfterUse::NO); \
}
#define FORWARD_DECLARE_FONT(n) \
Commit: 6d3927cd7a6e93452366085e179b156558f78a2b
https://github.com/scummvm/scummvm/commit/6d3927cd7a6e93452366085e179b156558f78a2b
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2012-03-28T10:17:13-07:00
Commit Message:
GRAPHICS: Take ownership of fonts passed to FontManager.
Changed paths:
graphics/fontman.cpp
graphics/fontman.h
diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp
index 8d967d5..99dd3d6 100644
--- a/graphics/fontman.cpp
+++ b/graphics/fontman.cpp
@@ -47,6 +47,13 @@ FontManager::FontManager() {
}
FontManager::~FontManager() {
+ for (uint i = 0; i < _ownedFonts.size(); ++i) {
+ const Font *font = _ownedFonts[i];
+ if (font == g_sysfont || font == g_sysfont_big || font == g_consolefont)
+ continue;
+ delete font;
+ }
+
delete g_sysfont;
g_sysfont = 0;
delete g_sysfont_big;
@@ -90,6 +97,8 @@ bool FontManager::assignFontToName(const Common::String &name, const Font *font)
Common::String lowercaseName = name;
lowercaseName.toLowercase();
_fontMap[lowercaseName] = font;
+ if (Common::find(_ownedFonts.begin(), _ownedFonts.end(), font) == _ownedFonts.end())
+ _ownedFonts.push_back(font);
return true;
}
@@ -116,8 +125,35 @@ bool FontManager::setFont(FontUsage usage, const BdfFont *font) {
void FontManager::removeFontName(const Common::String &name) {
Common::String lowercaseName = name;
lowercaseName.toLowercase();
+ if (!_fontMap.contains(lowercaseName))
+ return;
+
+ const Font *font = _fontMap[lowercaseName];
_fontMap.erase(lowercaseName);
+ // Check if we still have a copy of this font in the map.
+ bool stillHasFont = false;
+ for (Common::HashMap<Common::String, const Font *>::iterator i = _fontMap.begin(); i != _fontMap.end(); ++i) {
+ if (i->_value != font)
+ continue;
+ stillHasFont = true;
+ break;
+ }
+
+ if (!stillHasFont) {
+ // We don't have a copy of the font, so remove it from our list and delete it.
+ stillHasFont = true;
+ for (uint i = 0; i < _ownedFonts.size(); ++i) {
+ if (_ownedFonts[i] != font)
+ continue;
+ stillHasFont = false;
+ _ownedFonts.remove_at(i);
+ break;
+ }
+ assert(!stillHasFont);
+ delete font;
+ }
+
// In case the current localized font is removed, we fall back to the
// default font again.
if (_localizedFontName == lowercaseName)
diff --git a/graphics/fontman.h b/graphics/fontman.h
index 42f7d85..b06ddea 100644
--- a/graphics/fontman.h
+++ b/graphics/fontman.h
@@ -60,7 +60,9 @@ public:
const Font *getFontByName(const Common::String &name) const;
/**
- * Associates a font object with an 'name'
+ * Associates a font object with an 'name'.
+ * The FontManager takes ownership of the provided font object
+ * and will delete it when necesssary.
*
* @param name the name of the font
* @param font the font object
@@ -111,6 +113,7 @@ private:
~FontManager();
Common::HashMap<Common::String, const Font *> _fontMap;
+ Common::Array<const Font *> _ownedFonts;
Common::String _localizedFontName;
};
Commit: b470c9af28752a1f360bf8c459ffd8fdcca3e6fb
https://github.com/scummvm/scummvm/commit/b470c9af28752a1f360bf8c459ffd8fdcca3e6fb
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2012-03-28T10:17:53-07:00
Commit Message:
BASE: Free TTFLibrary singleton on shutdown.
This uses a helper function because TTFLibrary is internal.
Changed paths:
base/main.cpp
graphics/fonts/ttf.cpp
graphics/fonts/ttf.h
diff --git a/base/main.cpp b/base/main.cpp
index 6fb56b4..e103b70 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -57,6 +57,9 @@
#include "graphics/cursorman.h"
#include "graphics/fontman.h"
+#ifdef USE_FREETYPE2
+#include "graphics/fonts/ttf.h"
+#endif
#include "backends/keymapper/keymapper.h"
@@ -505,6 +508,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
MusicManager::destroy();
Graphics::CursorManager::destroy();
Graphics::FontManager::destroy();
+#ifdef USE_FREETYPE2
+ Graphics::shutdownTTF();
+#endif
return 0;
}
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 7505f79..7f5c616 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -70,6 +70,10 @@ private:
bool _initialized;
};
+void shutdownTTF() {
+ TTFLibrary::destroy();
+}
+
#define g_ttf ::Graphics::TTFLibrary::instance()
TTFLibrary::TTFLibrary() : _library(), _initialized(false) {
diff --git a/graphics/fonts/ttf.h b/graphics/fonts/ttf.h
index 7222d6e..ec7dbe0 100644
--- a/graphics/fonts/ttf.h
+++ b/graphics/fonts/ttf.h
@@ -34,6 +34,8 @@ namespace Graphics {
class Font;
Font *loadTTFFont(Common::SeekableReadStream &stream, int size, bool monochrome = false, const uint32 *mapping = 0);
+void shutdownTTF();
+
} // End of namespace Graphics
#endif
Commit: 29e05ec05eb85cc1402ebee2c399a4a45bcd4933
https://github.com/scummvm/scummvm/commit/29e05ec05eb85cc1402ebee2c399a4a45bcd4933
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2012-03-28T10:18:25-07:00
Commit Message:
OPENGL: Don't leak surfaces.
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 45804b5..cd820ae 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -70,6 +70,11 @@ OpenGLGraphicsManager::~OpenGLGraphicsManager() {
free(_gamePalette);
free(_cursorPalette);
+ _screenData.free();
+ _overlayData.free();
+ _cursorData.free();
+ _osdSurface.free();
+
delete _gameTexture;
delete _overlayTexture;
delete _cursorTexture;
Commit: b96143c1802b619553e476ad7a5a1eedeea0c768
https://github.com/scummvm/scummvm/commit/b96143c1802b619553e476ad7a5a1eedeea0c768
Author: Johannes Schickel (lordhoto at gmail.com)
Date: 2012-05-03T13:45:40-07:00
Commit Message:
Merge pull request #213 from fuzzie/leak-fixes
The pull request in question is "Memory leak fixes".
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
base/main.cpp
graphics/fontman.cpp
graphics/fontman.h
graphics/fonts/bdf.h
graphics/fonts/ttf.cpp
graphics/fonts/ttf.h
More information about the Scummvm-git-logs
mailing list