From b5262275297b4a005d826f51092abff6adc7041d Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 15 Dec 2015 10:22:49 -0500 Subject: [PATCH] Fixed crash on undo pad placement in the footprint editor using GAL canvases. (fixes lp:1525552) --- pcbnew/tools/module_tools.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pcbnew/tools/module_tools.cpp b/pcbnew/tools/module_tools.cpp index 511c24da19..3a5d9a3508 100644 --- a/pcbnew/tools/module_tools.cpp +++ b/pcbnew/tools/module_tools.cpp @@ -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 pads; std::set 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++ ) );