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 /src/resources/image.cpp | |
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.
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r-- | src/resources/image.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
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(); } |