Footprint editor: fix crashes when trying to edit the Default Pad Properties.
The crsahes were due to a null pointer use. Fixes #4379 https://gitlab.com/kicad/code/kicad/issues/4379
This commit is contained in:
parent
c78e7c5485
commit
acdfeee942
|
@ -85,18 +85,28 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem, wxString* a
|
||||||
|
|
||||||
// NB: we must check the net first, as when it is 0 GetNetClass() will return the
|
// NB: we must check the net first, as when it is 0 GetNetClass() will return the
|
||||||
// orphaned net netclass, not the default netclass.
|
// orphaned net netclass, not the default netclass.
|
||||||
if( m_netinfo->GetNet() == 0 )
|
if( GetBoard() )
|
||||||
netclass = GetBoard()->GetDesignSettings().GetDefault();
|
{
|
||||||
else
|
if( m_netinfo->GetNet() == 0 )
|
||||||
netclass = GetNetClass();
|
netclass = GetBoard()->GetDesignSettings().GetDefault();
|
||||||
|
else
|
||||||
|
netclass = GetNetClass();
|
||||||
|
}
|
||||||
|
// No clearance if "this" is not (yet) linked to a board therefore no available netclass
|
||||||
|
|
||||||
int myClearance = netclass->GetClearance();
|
int myClearance = netclass ? netclass->GetClearance() : 0;
|
||||||
|
|
||||||
if( aItem && aItem->GetClearance() > myClearance )
|
if( aItem && aItem->GetClearance() > myClearance )
|
||||||
return aItem->GetClearance( nullptr, aSource );
|
return aItem->GetClearance( nullptr, aSource );
|
||||||
|
|
||||||
if( aSource )
|
if( aSource )
|
||||||
*aSource = wxString::Format( _( "%s netclass clearance" ), netclass->GetName() );
|
{
|
||||||
|
if( netclass )
|
||||||
|
*aSource = wxString::Format( _( "%s netclass clearance" ),
|
||||||
|
netclass->GetName() );
|
||||||
|
else
|
||||||
|
*aSource = _( "No netclass" );
|
||||||
|
}
|
||||||
|
|
||||||
return myClearance;
|
return myClearance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,10 +101,15 @@ void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad )
|
||||||
|
|
||||||
if( dlg.ShowQuasiModal() == wxID_OK ) // QuasiModal required for NET_SELECTOR
|
if( dlg.ShowQuasiModal() == wxID_OK ) // QuasiModal required for NET_SELECTOR
|
||||||
{
|
{
|
||||||
FOOTPRINT_EDITOR_TOOLS* fpTools = m_toolManager->GetTool<FOOTPRINT_EDITOR_TOOLS>();
|
// aPad can be NULL, if the dialog is called from the footprint editor
|
||||||
|
// to set the default pad setup
|
||||||
|
if( aPad )
|
||||||
|
{
|
||||||
|
FOOTPRINT_EDITOR_TOOLS* fpTools = m_toolManager->GetTool<FOOTPRINT_EDITOR_TOOLS>();
|
||||||
|
|
||||||
if( fpTools )
|
if( fpTools )
|
||||||
fpTools->SetLastPadName( aPad->GetName() );
|
fpTools->SetLastPadName( aPad->GetName() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue