Fixed a memleak (CONDITIONAL_MENU).

This commit is contained in:
Maciej Suminski 2015-07-22 10:46:57 +02:00
parent 6cb57f100a
commit 83171482b3
2 changed files with 14 additions and 1 deletions

View File

@ -24,6 +24,15 @@
#include "conditional_menu.h"
CONDITIONAL_MENU::~CONDITIONAL_MENU()
{
for( std::list<ENTRY>::iterator it = m_entries.begin(); it != m_entries.end(); ++it )
{
if( it->Type() == ENTRY::MENU )
delete it->Menu();
}
}
void CONDITIONAL_MENU::AddItem( const TOOL_ACTION& aAction, const SELECTION_CONDITION& aCondition,
int aOrder )

View File

@ -35,6 +35,9 @@ class SELECTION_TOOL;
class CONDITIONAL_MENU
{
public:
CONDITIONAL_MENU() {}
~CONDITIONAL_MENU();
///> Constant to indicate that we do not care about an ENTRY location in the menu.
static const int ANY_ORDER = -1;
@ -54,7 +57,8 @@ public:
/**
* Function AddMenu()
*
* Adds a submenu to the menu.
* Adds a submenu to the menu. CONDITIONAL_MENU takes ownership of the added menu, so it will
* be freed when the CONDITIONAL_MENU object is destroyed.
* @param aMenu is the submenu to be added.
* @param aLabel is the label of added submenu.
* @param aExpand determines if the added submenu items should be added as individual items