Delete everything on exit

This commit is contained in:
simon.kagstrom 2010-01-23 14:55:15 +00:00
parent cd1768a140
commit 112154d17a
2 changed files with 31 additions and 1 deletions

22
gui.cpp
View File

@ -99,6 +99,26 @@ Gui::Gui()
this->bkv = NULL;
}
Gui::~Gui()
{
delete this->mv;
delete this->dv;
delete this->ov;
delete this->nv;
delete this->tv;
delete this->giv;
delete this->bkv;
delete this->cur_gameInfo;
delete this->timerController;
if (this->dlg)
delete this->dlg;
if (VirtualKeyboard::kbd)
delete VirtualKeyboard::kbd;
}
bool Gui::setTheme(const char *path)
{
this->bg_left = this->loadThemeImage(path, "bg_left.png");
@ -340,7 +360,7 @@ void Gui::saveGameInfo()
return;
}
int n = fwrite((const void*)p, 1, p->sz, fp);
if (n != p->sz)
if (n != (int)p->sz)
warning("Could only write %d bytes of %s\n", n, buf);
fclose(fp);
}

View File

@ -19,6 +19,9 @@ static void run(void)
SDL_Event ev;
Uint32 now = SDL_GetTicks();
if (!Gui::gui->is_active)
break;
while (SDL_PollEvent(&ev)) {
if (ev.type == SDL_QUIT)
exit(1);
@ -49,9 +52,16 @@ static void init(void)
Gui::gui->activate();
}
static void fini(void)
{
delete Gui::gui;
}
int main(int argc, char *argv[])
{
init();
run();
fini();
return 0;
}