aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-06-14 00:56:24 +0200
committerEinar Johan Trøan Sømåen2012-06-14 00:56:24 +0200
commitc1046889411d4f38babd21b1b38c0cbd457caf10 (patch)
tree8dc3cfa29b1fd088bd6036d749e2092ffb44c2d8 /engines
parent076ed07e9277ea0fd8b49c9dd8734de8d13145b1 (diff)
downloadscummvm-rg350-c1046889411d4f38babd21b1b38c0cbd457caf10.tar.gz
scummvm-rg350-c1046889411d4f38babd21b1b38c0cbd457caf10.tar.bz2
scummvm-rg350-c1046889411d4f38babd21b1b38c0cbd457caf10.zip
WINTERMUTE: Fix quite a lot of memory leaks.
Diffstat (limited to 'engines')
-rw-r--r--engines/wintermute/Base/BFontTT.cpp6
-rw-r--r--engines/wintermute/Base/BImage.cpp15
-rw-r--r--engines/wintermute/Base/BSurfaceSDL.cpp6
-rw-r--r--engines/wintermute/video/VidTheoraPlayer.cpp8
4 files changed, 25 insertions, 10 deletions
diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp
index 449767e359..c2991f1277 100644
--- a/engines/wintermute/Base/BFontTT.cpp
+++ b/engines/wintermute/Base/BFontTT.cpp
@@ -278,8 +278,12 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex
}
CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game);
- retSurface->putSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0)), true);
+ Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0));
+ retSurface->putSurface(*convertedSurface, true);
+ convertedSurface->free();
+ surface->free();
delete surface;
+ delete convertedSurface;
return retSurface;
#if 0 //TODO
int textHeight = lines.size() * (_maxCharHeight + _ascender);
diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp
index bacfd9ece5..69859b4c05 100644
--- a/engines/wintermute/Base/BImage.cpp
+++ b/engines/wintermute/Base/BImage.cpp
@@ -67,16 +67,15 @@ CBImage::~CBImage() {
HRESULT CBImage::loadFile(const Common::String &filename) {
_filename = filename;
- Graphics::ImageDecoder *imgDecoder;
if (filename.hasSuffix(".png")) {
- imgDecoder = new Graphics::PNGDecoder();
+ _decoder = new Graphics::PNGDecoder();
} else if (filename.hasSuffix(".bmp")) {
- imgDecoder = new Graphics::BitmapDecoder();
+ _decoder = new Graphics::BitmapDecoder();
} else if (filename.hasSuffix(".tga")) {
- imgDecoder = new WinterMute::TGA();
+ _decoder = new WinterMute::TGA();
} else if (filename.hasSuffix(".jpg")) {
- imgDecoder = new Graphics::JPEGDecoder();
+ _decoder = new Graphics::JPEGDecoder();
} else {
error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str());
}
@@ -84,9 +83,9 @@ HRESULT CBImage::loadFile(const Common::String &filename) {
Common::SeekableReadStream *file = Game->_fileManager->OpenFile(filename.c_str());
if (!file) return E_FAIL;
- imgDecoder->loadStream(*file);
- _surface = imgDecoder->getSurface();
- _palette = imgDecoder->getPalette();
+ _decoder->loadStream(*file);
+ _surface = _decoder->getSurface();
+ _palette = _decoder->getPalette();
Game->_fileManager->CloseFile(file);
return S_OK;
diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp
index 8c8c6d4fb9..ae7bad54b7 100644
--- a/engines/wintermute/Base/BSurfaceSDL.cpp
+++ b/engines/wintermute/Base/BSurfaceSDL.cpp
@@ -528,7 +528,11 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo
drawSrc.pixels = _scaledSurface->pixels;
drawSrc.pitch = _scaledSurface->pitch;
} else {
- delete _scaledSurface;
+ if (_scaledSurface) {
+ _scaledSurface->free();
+ delete _scaledSurface;
+ _scaledSurface = NULL;
+ }
TransparentSurface src(*_surface, false);
_scaledSurface = src.scale(position.width(), position.height());
drawSrc.pixels = _scaledSurface->pixels;
diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp
index ca01b51d6f..33ef835933 100644
--- a/engines/wintermute/video/VidTheoraPlayer.cpp
+++ b/engines/wintermute/video/VidTheoraPlayer.cpp
@@ -74,6 +74,7 @@ void CVidTheoraPlayer::SetDefaults() {
_savedState = THEORA_STATE_NONE;
_savedPos = 0;
_volume = 100;
+ _theoraDecoder = NULL;
#if 0
_vorbisStreams = _theoraStreams = 0;
@@ -96,6 +97,13 @@ CVidTheoraPlayer::~CVidTheoraPlayer(void) {
//////////////////////////////////////////////////////////////////////////
void CVidTheoraPlayer::cleanup() {
+ _surface.free();
+ delete _theoraDecoder;
+ _theoraDecoder = NULL;
+ delete _alphaImage;
+ _alphaImage = NULL;
+ delete _texture;
+ _texture = NULL;
#if 0
if (m_Sound) {
Game->m_SoundMgr->RemoveSound(m_Sound);