1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-23 05:15:20 +02:00

Surface: Use the destructor as intended.

There is no reason to have an explicit free() method instead of just
destructing the Surface object and doing cleanup in the destructor.
This commit is contained in:
Maarten ter Huurne 2011-06-02 18:15:15 +02:00
parent 0c867aabbf
commit 0a9229ff3f
4 changed files with 2 additions and 13 deletions

View File

@ -327,7 +327,7 @@ GMenu2X::~GMenu2X() {
void GMenu2X::quit() { void GMenu2X::quit() {
fflush(NULL); fflush(NULL);
sc.clear(); sc.clear();
s->free(); free(s);
SDL_Quit(); SDL_Quit();
#ifdef TARGET_GP2X #ifdef TARGET_GP2X
/* if (gp2x_mem!=0) { /* if (gp2x_mem!=0) {

View File

@ -66,10 +66,6 @@ Surface::Surface(const string &img, const string &skin) {
} }
Surface::~Surface() { Surface::~Surface() {
free();
}
void Surface::free() {
if (freeWhenDone) { if (freeWhenDone) {
SDL_FreeSurface(raw); SDL_FreeSurface(raw);
} }
@ -83,8 +79,6 @@ SDL_PixelFormat *Surface::format() {
} }
void Surface::load(const string &img, const string &skin) { void Surface::load(const string &img, const string &skin) {
free();
string skinpath; string skinpath;
if (!skin.empty() && !img.empty() && img[0]!='/') { if (!skin.empty() && !img.empty() && img[0]!='/') {
skinpath = "skins/"+skin+"/"+img; skinpath = "skins/"+skin+"/"+img;

View File

@ -47,7 +47,6 @@ public:
SDL_Surface *raw; SDL_Surface *raw;
void free();
void flip(); void flip();
void clearClipRect(); void clearClipRect();

View File

@ -109,11 +109,7 @@ void SurfaceCollection::del(const string &path) {
} }
void SurfaceCollection::clear() { void SurfaceCollection::clear() {
while (surfaces.size()>0) { surfaces.clear();
surfaces.begin()->second->free();
free(surfaces.begin()->second);
surfaces.erase(surfaces.begin());
}
} }
void SurfaceCollection::move(const string &from, const string &to) { void SurfaceCollection::move(const string &from, const string &to) {