Minor code cleaning.

This commit is contained in:
Maciej Suminski 2015-04-30 10:46:03 +02:00
parent c4888afbcc
commit 50afd515c2
1 changed files with 21 additions and 41 deletions

View File

@ -99,16 +99,9 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL() EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
{ {
if( m_painter )
delete m_painter; delete m_painter;
if( m_viewControls )
delete m_viewControls; delete m_viewControls;
if( m_view )
delete m_view; delete m_view;
if( m_gal )
delete m_gal; delete m_gal;
} }
@ -194,42 +187,29 @@ void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
m_eventDispatcher = aEventDispatcher; m_eventDispatcher = aEventDispatcher;
#if wxCHECK_VERSION( 3, 0, 0 ) #if wxCHECK_VERSION( 3, 0, 0 )
if( m_eventDispatcher ) const wxEventType eventTypes[] = { wxEVT_TOOL };
{
m_parent->Connect( wxEVT_TOOL,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
}
else
{
// While loops are used to be sure, that we are removing all event handlers
while( m_parent->Disconnect( wxEVT_TOOL,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) );
}
#else #else
const wxEventType eventTypes[] = { wxEVT_COMMAND_MENU_SELECTED, wxEVT_COMMAND_TOOL_CLICKED };
#endif
if( m_eventDispatcher ) if( m_eventDispatcher )
{ {
m_parent->Connect( wxEVT_COMMAND_MENU_SELECTED, BOOST_FOREACH( wxEventType type, eventTypes )
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ), {
NULL, m_eventDispatcher ); m_parent->Connect( type, wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
m_parent->Connect( wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ); NULL, m_eventDispatcher );
} }
}
else else
{ {
// While loops are used to be sure, that we are removing all event handlers BOOST_FOREACH( wxEventType type, eventTypes )
while( m_parent->Disconnect( wxEVT_COMMAND_MENU_SELECTED, {
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ), // While loop is used to be sure that all event handlers are removed.
NULL, m_eventDispatcher ) ); while( m_parent->Disconnect( type,
while( m_parent->Disconnect( wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ), wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) ); NULL, m_eventDispatcher ) );
} }
#endif }
} }