mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2025-02-18 12:24:42 +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:
parent
5a27851aea
commit
81a607c36e
@ -400,15 +400,14 @@ GMenu2X::~GMenu2X() {
|
|||||||
|
|
||||||
quit();
|
quit();
|
||||||
|
|
||||||
free(menu);
|
delete menu;
|
||||||
free(s);
|
delete font;
|
||||||
free(font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::quit() {
|
void GMenu2X::quit() {
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
sc.clear();
|
sc.clear();
|
||||||
free(s);
|
delete s;
|
||||||
|
|
||||||
#ifdef UNLOCK_VT
|
#ifdef UNLOCK_VT
|
||||||
SDL_QuitSubSystem(SDL_INIT_EVERYTHING & ~SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_EVERYTHING & ~SDL_INIT_VIDEO);
|
||||||
@ -433,7 +432,7 @@ void GMenu2X::initBG() {
|
|||||||
sc.del("bgmain");
|
sc.del("bgmain");
|
||||||
|
|
||||||
// Load wallpaper.
|
// Load wallpaper.
|
||||||
free(bg);
|
delete bg;
|
||||||
bg = Surface::loadImage(confStr["wallpaper"]);
|
bg = Surface::loadImage(confStr["wallpaper"]);
|
||||||
if (!bg) {
|
if (!bg) {
|
||||||
bg = Surface::emptySurface(resX, resY);
|
bg = Surface::emptySurface(resX, resY);
|
||||||
@ -449,20 +448,20 @@ void GMenu2X::initBG() {
|
|||||||
if (sd) sd->blit(bgmain, 3, bottomBarIconY);
|
if (sd) sd->blit(bgmain, 3, bottomBarIconY);
|
||||||
string df = getDiskFree();
|
string df = getDiskFree();
|
||||||
bgmain->write(font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
bgmain->write(font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||||
free(sd);
|
delete sd;
|
||||||
|
|
||||||
Surface *volume = Surface::loadImage("imgs/volume.png", confStr["skin"]);
|
Surface *volume = Surface::loadImage("imgs/volume.png", confStr["skin"]);
|
||||||
volumeX = 27+font->getTextWidth(df);
|
volumeX = 27+font->getTextWidth(df);
|
||||||
if (volume) volume->blit(bgmain, volumeX, bottomBarIconY);
|
if (volume) volume->blit(bgmain, volumeX, bottomBarIconY);
|
||||||
volumeX += 19;
|
volumeX += 19;
|
||||||
free(volume);
|
delete volume;
|
||||||
|
|
||||||
Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]);
|
Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]);
|
||||||
cpuX = volumeX+font->getTextWidth("100")+5;
|
cpuX = volumeX+font->getTextWidth("100")+5;
|
||||||
if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY);
|
if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY);
|
||||||
cpuX += 19;
|
cpuX += 19;
|
||||||
manualX = cpuX+font->getTextWidth("300Mhz")+5;
|
manualX = cpuX+font->getTextWidth("300Mhz")+5;
|
||||||
free(cpu);
|
delete cpu;
|
||||||
|
|
||||||
int serviceX = resX-38;
|
int serviceX = resX-38;
|
||||||
if (usbnet) {
|
if (usbnet) {
|
||||||
@ -471,20 +470,20 @@ void GMenu2X::initBG() {
|
|||||||
"imgs/webserver.png", confStr["skin"]);
|
"imgs/webserver.png", confStr["skin"]);
|
||||||
if (webserver) webserver->blit(bgmain, serviceX, bottomBarIconY);
|
if (webserver) webserver->blit(bgmain, serviceX, bottomBarIconY);
|
||||||
serviceX -= 19;
|
serviceX -= 19;
|
||||||
free(webserver);
|
delete webserver;
|
||||||
}
|
}
|
||||||
if (samba) {
|
if (samba) {
|
||||||
Surface *sambaS = Surface::loadImage(
|
Surface *sambaS = Surface::loadImage(
|
||||||
"imgs/samba.png", confStr["skin"]);
|
"imgs/samba.png", confStr["skin"]);
|
||||||
if (sambaS) sambaS->blit(bgmain, serviceX, bottomBarIconY);
|
if (sambaS) sambaS->blit(bgmain, serviceX, bottomBarIconY);
|
||||||
serviceX -= 19;
|
serviceX -= 19;
|
||||||
free(sambaS);
|
delete sambaS;
|
||||||
}
|
}
|
||||||
if (inet) {
|
if (inet) {
|
||||||
Surface *inetS = Surface::loadImage("imgs/inet.png", confStr["skin"]);
|
Surface *inetS = Surface::loadImage("imgs/inet.png", confStr["skin"]);
|
||||||
if (inetS) inetS->blit(bgmain, serviceX, bottomBarIconY);
|
if (inetS) inetS->blit(bgmain, serviceX, bottomBarIconY);
|
||||||
serviceX -= 19;
|
serviceX -= 19;
|
||||||
free(inetS);
|
delete inetS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +492,7 @@ void GMenu2X::initBG() {
|
|||||||
|
|
||||||
void GMenu2X::initFont() {
|
void GMenu2X::initFont() {
|
||||||
if (font != NULL) {
|
if (font != NULL) {
|
||||||
free(font);
|
delete font;
|
||||||
font = NULL;
|
font = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ void LinkApp::showManual() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(bg);
|
delete bg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void Menu::loadIcons() {
|
|||||||
void Menu::freeLinks() {
|
void Menu::freeLinks() {
|
||||||
for (vector<linklist>::iterator section = links.begin(); section<links.end(); section++)
|
for (vector<linklist>::iterator section = links.begin(); section<links.end(); section++)
|
||||||
for (linklist::iterator link = section->begin(); link<section->end(); link++)
|
for (linklist::iterator link = section->begin(); link<section->end(); link++)
|
||||||
free(*link);
|
delete *link;
|
||||||
}
|
}
|
||||||
|
|
||||||
linklist *Menu::sectionLinks(int i) {
|
linklist *Menu::sectionLinks(int i) {
|
||||||
@ -454,7 +454,7 @@ void Menu::readLinks() {
|
|||||||
if (link->targetExists())
|
if (link->targetExists())
|
||||||
links[i].push_back( link );
|
links[i].push_back( link );
|
||||||
else
|
else
|
||||||
free(link);
|
delete link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ SettingsDialog::SettingsDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialog::~SettingsDialog() {
|
SettingsDialog::~SettingsDialog() {
|
||||||
for (uint i=0; i<voices.size(); i++)
|
for (vector<MenuSetting *>::iterator it = voices.begin(); it != voices.end(); ++it)
|
||||||
free(voices[i]);
|
delete *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsDialog::exec() {
|
bool SettingsDialog::exec() {
|
||||||
|
@ -139,7 +139,7 @@ Surface *SurfaceCollection::addSkinRes(const string &path, bool useDefault) {
|
|||||||
void SurfaceCollection::del(const string &path) {
|
void SurfaceCollection::del(const string &path) {
|
||||||
SurfaceHash::iterator i = surfaces.find(path);
|
SurfaceHash::iterator i = surfaces.find(path);
|
||||||
if (i != surfaces.end()) {
|
if (i != surfaces.end()) {
|
||||||
free(i->second);
|
delete i->second;
|
||||||
surfaces.erase(i);
|
surfaces.erase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user