diff options
-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(); } |