Fixed major ZImage Memory Leak in Attach

This commit is contained in:
James Turk 2002-12-21 08:40:15 +00:00
parent 844b2adacd
commit 8f2480b92f
2 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,9 @@
ZEngine Version Log for Version 0.8.0-rc2 ZEngine Version Log for Version 0.8.0-rc3
$Id: changelog.txt,v 1.11 2002/12/12 04:34:18 cozman Exp $ $Id: changelog.txt,v 1.12 2002/12/21 08:40:15 cozman Exp $
0.8.0-rc3
-Fixed MAJOR memory leak when using ZImage::Attach, and in ZFont.
-Updated ZEngine web info. (mostly in rc2)
0.8.0-rc2 0.8.0-rc2
-Added path stripping to ZEngine.linux.doxygen. -Added path stripping to ZEngine.linux.doxygen.

View File

@ -13,7 +13,7 @@
File: ZE_ZImage.cpp <br> File: ZE_ZImage.cpp <br>
Description: Implementation source file for core ZEngine Image or Texture Object. <br> Description: Implementation source file for core ZEngine Image or Texture Object. <br>
Author(s): James Turk, Gamer Tazar <br> Author(s): James Turk, Gamer Tazar <br>
$Id: ZE_ZImage.cpp,v 1.6 2002/12/02 05:46:37 cozman Exp $<br> $Id: ZE_ZImage.cpp,v 1.7 2002/12/21 08:40:15 cozman Exp $<br>
\file ZE_ZImage.cpp \file ZE_ZImage.cpp
\brief Source file for ZImage. \brief Source file for ZImage.
@ -59,7 +59,6 @@ void ZImage::Open(string filename)
{ {
SDL_Surface *image; SDL_Surface *image;
Release();
image = rEngine->LoadImage(filename.c_str()); image = rEngine->LoadImage(filename.c_str());
Attach(image); Attach(image);
} }
@ -71,8 +70,6 @@ void ZImage::OpenFromImage(SDL_Surface *image, Sint16 x, Sint16 y, Sint16 w, Sin
SDL_Rect rect; SDL_Rect rect;
SDL_VideoInfo *videoInfo; SDL_VideoInfo *videoInfo;
Release();
//either set hardware or software surface// //either set hardware or software surface//
videoInfo = const_cast<SDL_VideoInfo*>(SDL_GetVideoInfo()); videoInfo = const_cast<SDL_VideoInfo*>(SDL_GetVideoInfo());
@ -98,6 +95,8 @@ void ZImage::Attach(SDL_Surface *surface)
{ {
GLfloat coord[4]; GLfloat coord[4];
Release(); //avoid most memory leaks
if(surface) if(surface)
{ {
rWidth = surface->w; rWidth = surface->w;