diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-09-07 20:01:48 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-09-07 20:01:48 +0000 |
commit | ad98a108157ee171da5fac9f3af5cfd00501ff05 (patch) | |
tree | 7d9ca085fb3b4d48941dc8fd539cd20bc9b238d7 | |
parent | 57a863cc92f5316fb8225719385c4284f8c92e8e (diff) | |
download | mana-ad98a108157ee171da5fac9f3af5cfd00501ff05.tar.gz mana-ad98a108157ee171da5fac9f3af5cfd00501ff05.tar.bz2 mana-ad98a108157ee171da5fac9f3af5cfd00501ff05.tar.xz mana-ad98a108157ee171da5fac9f3af5cfd00501ff05.zip |
Worked around a memory leak when using OpenGL.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/resources/image.cpp | 21 |
2 files changed, 22 insertions, 5 deletions
@@ -1,4 +1,10 @@ +2006-09-07 Björn Steinbrink <B.Steinbrink@gmx.de> + + * src/resources/image.cpp: Worked around a memory leak when using + OpenGL. + 2006-09-06 Philipp Sehmisch <tmw@crushnet.org> + * data/graphics/sprites/item010.png, data/graphics/sprites/item010.xml, data/graphics/sprites/Makefile.am: Added santa hat sprites and updated makefile. diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 51899d3f..6a7c79df 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -260,11 +260,18 @@ void Image::unload() { mLoaded = false; - if (!mImage) return; + if (!mImage) { + // Free the image surface. + SDL_FreeSurface(mImage); + mImage = NULL; + } - // Free the image surface. - SDL_FreeSurface(mImage); - mImage = NULL; +#ifdef USE_OPENGL + if (mGLImage) { + glDeleteTextures(1, &mGLImage); + mGLImage = 0; + } +#endif } Image *Image::getSubImage(int x, int y, int width, int height) @@ -341,7 +348,11 @@ SubImage::SubImage(Image *parent, GLuint image, SubImage::~SubImage() { - mImage = 0; // Avoid destruction of the image + // Avoid destruction of the image + mImage = 0; +#ifdef USE_OPENGL + mGLImage = 0; +#endif mParent->decRef(); } |