diff --git a/pcbnew/board_connected_item.cpp b/pcbnew/board_connected_item.cpp index 4e26463a80..0f975d9fa4 100644 --- a/pcbnew/board_connected_item.cpp +++ b/pcbnew/board_connected_item.cpp @@ -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 // orphaned net netclass, not the default netclass. - if( m_netinfo->GetNet() == 0 ) - netclass = GetBoard()->GetDesignSettings().GetDefault(); - else - netclass = GetNetClass(); + if( GetBoard() ) + { + if( m_netinfo->GetNet() == 0 ) + 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 ) return aItem->GetClearance( nullptr, 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; } diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 4522d89060..78ddd4ce7f 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -101,10 +101,15 @@ void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad ) if( dlg.ShowQuasiModal() == wxID_OK ) // QuasiModal required for NET_SELECTOR { - FOOTPRINT_EDITOR_TOOLS* fpTools = m_toolManager->GetTool(); + // 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(); - if( fpTools ) - fpTools->SetLastPadName( aPad->GetName() ); + if( fpTools ) + fpTools->SetLastPadName( aPad->GetName() ); + } } }