diff --git a/gui.cpp b/gui.cpp index 8474be8..6730d04 100644 --- a/gui.cpp +++ b/gui.cpp @@ -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); } diff --git a/main.cpp b/main.cpp index a077fd4..93fbd0d 100644 --- a/main.cpp +++ b/main.cpp @@ -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; }