Commit d13355f7 authored by Maciej Suminski's avatar Maciej Suminski

Removed some potential memory leaks.

parent f179183d
......@@ -86,6 +86,19 @@ TOOL_MANAGER::TOOL_MANAGER()
}
TOOL_MANAGER::~TOOL_MANAGER()
{
std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end;
for( it = m_toolState.begin(), it_end = m_toolState.end(); it != it_end; ++it )
{
delete it->second->cofunc; // delete cofunction
delete it->second; // delete TOOL_STATE
delete it->first; // delete the tool itself
}
}
void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
{
TOOL_STATE* st = new TOOL_STATE;
......
......@@ -95,8 +95,8 @@ protected:
/// main window.
wxAuiToolBar* m_auxiliaryToolBar;
TOOL_MANAGER *m_toolManager;
TOOL_DISPATCHER *m_toolDispatcher;
TOOL_MANAGER* m_toolManager;
TOOL_DISPATCHER* m_toolDispatcher;
void updateGridSelectBox();
void updateZoomSelectBox();
......
......@@ -118,6 +118,7 @@ protected:
// to know the footprint name of components.
void setupTools();
void destroyTools();
void onGenericCommand( wxCommandEvent& aEvent );
// we'll use lower case function names for private member functions.
......
......@@ -485,6 +485,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
{
destroyTools();
m_RecordingMacros = -1;
for( int i = 0; i < 10; i++ )
......
......@@ -50,6 +50,13 @@ void PCB_EDIT_FRAME::setupTools()
}
void PCB_EDIT_FRAME::destroyTools()
{
delete m_toolDispatcher;
delete m_toolManager;
}
void PCB_EDIT_FRAME::onGenericCommand( wxCommandEvent &aEvent )
{
m_toolDispatcher->DispatchWxCommand( aEvent );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment