Free views when popping them

This commit is contained in:
simon.kagstrom 2009-12-06 19:21:48 +00:00
parent 32e422327c
commit e50b1a1045
2 changed files with 25 additions and 3 deletions

15
gui.cpp
View File

@ -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)

View File

@ -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;