Fixed crash on undo pad placement in the footprint editor using GAL canvases. (fixes lp:1525552)

This commit is contained in:
Maciej Suminski 2015-12-15 10:22:49 -05:00 committed by Wayne Stambaugh
parent e93c815e02
commit b526227529
1 changed files with 10 additions and 11 deletions

View File

@ -105,10 +105,9 @@ int MODULE_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
MODULE* module = m_board->m_Modules;
assert( module );
assert( m_board->m_Modules );
D_PAD* pad = new D_PAD( module );
D_PAD* pad = new D_PAD( m_board->m_Modules );
m_frame->Import_Pad_Settings( pad, false ); // use the global settings for pad
VECTOR2I cursorPos = m_controls->GetCursorPosition();
@ -159,11 +158,12 @@ int MODULE_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
else if( evt->IsClick( BUT_LEFT ) )
{
m_frame->OnModify();
m_frame->SaveCopyInUndoList( module, UR_MODEDIT );
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_MODEDIT );
m_board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
module->SetLastEditTime();
module->Pads().PushBack( pad );
pad->SetParent( m_board->m_Modules );
m_board->m_Modules->SetLastEditTime();
m_board->m_Modules->Pads().PushBack( pad );
// Set the relative pad position
// ( pad position for module orient, 0, and relative to the module position)
@ -177,7 +177,7 @@ int MODULE_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
m_view->Add( pad );
// Start placing next pad
pad = new D_PAD( module );
pad = new D_PAD( m_board->m_Modules );
m_frame->Import_Pad_Settings( pad, false );
pad->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
preview.Add( pad );
@ -199,9 +199,8 @@ int MODULE_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
{
std::list<D_PAD*> pads;
std::set<D_PAD*> allPads;
MODULE* module = m_board->m_Modules;
if( !module || !module->Pads() )
if( !m_board->m_Modules || !m_board->m_Modules->Pads() )
return 0;
GENERAL_COLLECTOR collector;
@ -215,7 +214,7 @@ int MODULE_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
guide.SetIgnoreModulesRefs( true );
// Create a set containing all pads (to avoid double adding to the list)
for( D_PAD* p = module->Pads(); p; p = p->Next() )
for( D_PAD* p = m_board->m_Modules->Pads(); p; p = p->Next() )
allPads.insert( p );
DIALOG_ENUM_PADS settingsDlg( m_frame );
@ -309,7 +308,7 @@ int MODULE_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
{
// Accept changes
m_frame->OnModify();
m_frame->SaveCopyInUndoList( module, UR_MODEDIT );
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_MODEDIT );
BOOST_FOREACH( D_PAD* pad, pads )
pad->SetPadName( wxString::Format( wxT( "%s%d" ), padPrefix.c_str(), padNumber++ ) );