Fixed crash on right click on zone with GAL mode.

This commit is contained in:
Tomasz Wlostowski 2015-08-03 11:53:58 +02:00 committed by Maciej Suminski
parent 5f4423f7af
commit 9c2bcb2f3c
7 changed files with 30 additions and 18 deletions

View File

@ -194,6 +194,14 @@ void CONTEXT_MENU::UpdateAll()
}
void CONTEXT_MENU::SetTool( TOOL_INTERACTIVE* aTool )
{
m_tool = aTool;
runOnSubmenus( boost::bind( &CONTEXT_MENU::SetTool, _1, aTool ) );
}
TOOL_MANAGER* CONTEXT_MENU::getToolManager()
{
assert( m_tool );
@ -293,14 +301,6 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
}
void CONTEXT_MENU::setTool( TOOL_INTERACTIVE* aTool )
{
m_tool = aTool;
runOnSubmenus( boost::bind( &CONTEXT_MENU::setTool, _1, aTool ) );
}
void CONTEXT_MENU::runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent )
{
aToolEvent = m_menu_handler( aMenuEvent );

View File

@ -66,6 +66,6 @@ void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIS
void TOOL_INTERACTIVE::SetContextMenu( CONTEXT_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger )
{
aMenu->setTool( this );
aMenu->SetTool( this );
m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
}

View File

@ -147,6 +147,13 @@ public:
m_update_handler = aUpdateHandler;
}
/**
* Function SetTool()
* Sets a tool that is the creator of the menu.
* @param aTool is the tool that created the menu.
*/
void SetTool( TOOL_INTERACTIVE* aTool );
protected:
///> Returns an instance of TOOL_MANAGER class.
TOOL_MANAGER* getToolManager();
@ -177,13 +184,6 @@ private:
///> The default menu event handler.
void onMenuEvent( wxMenuEvent& aEvent );
/**
* Function setTool()
* Sets a tool that is the creator of the menu.
* @param aTool is the tool that created the menu.
*/
void setTool( TOOL_INTERACTIVE* aTool );
///> Updates hot key settings for TOOL_ACTIONs in this menu.
void updateHotKeys();

View File

@ -49,6 +49,7 @@ void CONDITIONAL_MENU::AddSeparator( const SELECTION_CONDITION& aCondition, int
CONTEXT_MENU* CONDITIONAL_MENU::Generate( SELECTION& aSelection )
{
CONTEXT_MENU* m_menu = new CONTEXT_MENU;
m_menu->SetTool( m_tool );
for( std::list<ENTRY>::iterator it = m_entries.begin(); it != m_entries.end(); ++it )
{

View File

@ -31,6 +31,7 @@
class SELECTION_TOOL;
class TOOL_ACTION;
class TOOL_INTERACTIVE;
class CONTEXT_MENU;
class CONDITIONAL_MENU
@ -39,6 +40,10 @@ public:
///> Constant to indicate that we do not care about an ENTRY location in the menu.
static const int ANY_ORDER = -1;
CONDITIONAL_MENU( TOOL_INTERACTIVE* aTool ) :
m_tool( aTool )
{}
/**
* Function AddItem()
*
@ -208,6 +213,9 @@ private:
///> List of all menu entries.
std::list<ENTRY> m_entries;
///> tool owning the menu
TOOL_INTERACTIVE* m_tool;
};
#endif /* CONDITIONAL_MENU_H */

View File

@ -117,6 +117,7 @@ bool PCB_EDITOR_CONTROL::Init()
if( selTool )
{
m_zoneMenu = new ZONE_CONTEXT_MENU;
m_zoneMenu->SetTool( this );
selTool->GetMenu().AddMenu( m_zoneMenu, _( "Zones" ), false,
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
}

View File

@ -70,8 +70,8 @@ public:
SELECTION_TOOL::SELECTION_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ),
m_frame( NULL ), m_additive( false ), m_multiple( false ),
m_editModules( false ), m_locked( true ), m_contextMenu( NULL ), m_selectMenu( NULL )
m_frame( NULL ), m_additive( false ), m_multiple( false ), m_editModules( false ),
m_locked( true ), m_menu( this ), m_contextMenu( NULL ), m_selectMenu( NULL )
{
// Do not leave uninitialized members:
m_preliminary = false;
@ -91,6 +91,8 @@ bool SELECTION_TOOL::Init()
m_selection.group = new KIGFX::VIEW_GROUP;
m_selectMenu = new SELECT_MENU;
m_selectMenu->SetTool( this );
m_menu.AddMenu( m_selectMenu, _( "Select..." ), false,
( SELECTION_CONDITIONS::OnlyType( PCB_VIA_T ) || SELECTION_CONDITIONS::OnlyType( PCB_TRACE_T ) ) &&
SELECTION_CONDITIONS::Count( 1 ) );