diff --git a/gui.cpp b/gui.cpp index c9b36ee..86163f3 100644 --- a/gui.cpp +++ b/gui.cpp @@ -128,11 +128,18 @@ void Gui::pushView(GuiView *view) GuiView *Gui::popView() { + GuiView *cur = this->peekView(); + + if (cur) + delete cur; + this->n_views--; if (this->n_views <= 0) { - this->n_views = 0; free(this->views); + this->views = NULL; + this->n_views = 0; + return NULL; } @@ -144,8 +151,10 @@ GuiView *Gui::popView() void Gui::exitMenu() { printf("Exiting the menu system\n"); - free(this->views); - this->views = NULL; + + /* Pop all views */ + while (this->popView()) + ; } void Gui::pushEvent(SDL_Event *ev) diff --git a/main_menu.cpp b/main_menu.cpp index 2daadc4..640f46b 100644 --- a/main_menu.cpp +++ b/main_menu.cpp @@ -1,3 +1,5 @@ +#include "menu.hh" + class MainView; class MainMenu : public Menu { @@ -63,6 +65,11 @@ public: printf("entry %d selected: %s\n", which, this->pp_msgs[which]); switch (which) { + case 1: + if (this->p_submenus[0].sel == 0) + ; + break; + case 11: this->dialogue = new ExitDialogue(this->font); this->dialogue->setSelectedBackground(NULL, NULL, NULL, @@ -103,6 +110,12 @@ public: this->dialogue_bg = NULL; } + ~MainView() + { + delete this->help; + delete this->menu; + } + void updateTheme() { this->bg = parent->main_menu_bg;