1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-27 11:21:45 +02:00

Fixed a good number of memory leaks.

The objects created with "new" were destroyed with "free()",
instead of "delete"; as a result, the destructors were never called.
This commit is contained in:
Ayla 2011-07-20 13:43:25 +02:00
parent 5a27851aea
commit 81a607c36e
5 changed files with 17 additions and 18 deletions

View File

@ -400,15 +400,14 @@ GMenu2X::~GMenu2X() {
quit();
free(menu);
free(s);
free(font);
delete menu;
delete font;
}
void GMenu2X::quit() {
fflush(NULL);
sc.clear();
free(s);
delete s;
#ifdef UNLOCK_VT
SDL_QuitSubSystem(SDL_INIT_EVERYTHING & ~SDL_INIT_VIDEO);
@ -433,7 +432,7 @@ void GMenu2X::initBG() {
sc.del("bgmain");
// Load wallpaper.
free(bg);
delete bg;
bg = Surface::loadImage(confStr["wallpaper"]);
if (!bg) {
bg = Surface::emptySurface(resX, resY);
@ -449,20 +448,20 @@ void GMenu2X::initBG() {
if (sd) sd->blit(bgmain, 3, bottomBarIconY);
string df = getDiskFree();
bgmain->write(font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle);
free(sd);
delete sd;
Surface *volume = Surface::loadImage("imgs/volume.png", confStr["skin"]);
volumeX = 27+font->getTextWidth(df);
if (volume) volume->blit(bgmain, volumeX, bottomBarIconY);
volumeX += 19;
free(volume);
delete volume;
Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]);
cpuX = volumeX+font->getTextWidth("100")+5;
if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY);
cpuX += 19;
manualX = cpuX+font->getTextWidth("300Mhz")+5;
free(cpu);
delete cpu;
int serviceX = resX-38;
if (usbnet) {
@ -471,20 +470,20 @@ void GMenu2X::initBG() {
"imgs/webserver.png", confStr["skin"]);
if (webserver) webserver->blit(bgmain, serviceX, bottomBarIconY);
serviceX -= 19;
free(webserver);
delete webserver;
}
if (samba) {
Surface *sambaS = Surface::loadImage(
"imgs/samba.png", confStr["skin"]);
if (sambaS) sambaS->blit(bgmain, serviceX, bottomBarIconY);
serviceX -= 19;
free(sambaS);
delete sambaS;
}
if (inet) {
Surface *inetS = Surface::loadImage("imgs/inet.png", confStr["skin"]);
if (inetS) inetS->blit(bgmain, serviceX, bottomBarIconY);
serviceX -= 19;
free(inetS);
delete inetS;
}
}
@ -493,7 +492,7 @@ void GMenu2X::initBG() {
void GMenu2X::initFont() {
if (font != NULL) {
free(font);
delete font;
font = NULL;
}

View File

@ -365,7 +365,7 @@ void LinkApp::showManual() {
break;
}
}
free(bg);
delete bg;
return;
}

View File

@ -116,7 +116,7 @@ void Menu::loadIcons() {
void Menu::freeLinks() {
for (vector<linklist>::iterator section = links.begin(); section<links.end(); section++)
for (linklist::iterator link = section->begin(); link<section->end(); link++)
free(*link);
delete *link;
}
linklist *Menu::sectionLinks(int i) {
@ -454,7 +454,7 @@ void Menu::readLinks() {
if (link->targetExists())
links[i].push_back( link );
else
free(link);
delete link;
}
}
}

View File

@ -40,8 +40,8 @@ SettingsDialog::SettingsDialog(
}
SettingsDialog::~SettingsDialog() {
for (uint i=0; i<voices.size(); i++)
free(voices[i]);
for (vector<MenuSetting *>::iterator it = voices.begin(); it != voices.end(); ++it)
delete *it;
}
bool SettingsDialog::exec() {

View File

@ -139,7 +139,7 @@ Surface *SurfaceCollection::addSkinRes(const string &path, bool useDefault) {
void SurfaceCollection::del(const string &path) {
SurfaceHash::iterator i = surfaces.find(path);
if (i != surfaces.end()) {
free(i->second);
delete i->second;
surfaces.erase(i);
}
}