Fix order of initialization resulting in net assignment getting lost.

Fixes https://gitlab.com/kicad/code/kicad/issues/12168
This commit is contained in:
Jeff Young 2022-08-05 23:32:26 +01:00
parent 24e7a8ac41
commit 6a9b821b5c
1 changed files with 13 additions and 26 deletions

View File

@ -79,7 +79,6 @@ private:
void readNetInformation(); void readNetInformation();
void readFilteringAndSortingCriteria(); void readFilteringAndSortingCriteria();
void buildListOfNets( const NETINFO_LIST& nets );
wxArrayString buildListOfNetsToDisplay(); wxArrayString buildListOfNetsToDisplay();
void sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets, const int maxNetCode ); void sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets, const int maxNetCode );
void updateDisplayedListOfNets(); void updateDisplayedListOfNets();
@ -386,24 +385,15 @@ void DIALOG_COPPER_ZONE::readNetInformation()
{ {
NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo(); NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
if( netInfoList.GetNetCount() > 0 )
{
buildListOfNets( netInfoList );
}
}
void DIALOG_COPPER_ZONE::buildListOfNets( const NETINFO_LIST& nets )
{
m_netInfoItemList.clear(); m_netInfoItemList.clear();
m_netInfoItemList.reserve( nets.GetNetCount() ); m_netInfoItemList.reserve( netInfoList.GetNetCount() );
m_netNameToNetCode.clear(); m_netNameToNetCode.clear();
m_netNameToNetCode[wxT( "<no net>" )] = INVALID_NET_CODE; m_netNameToNetCode[wxT( "<no net>" )] = INVALID_NET_CODE;
m_maxNetCode = INVALID_NET_CODE; m_maxNetCode = INVALID_NET_CODE;
for( NETINFO_ITEM* net : nets ) for( NETINFO_ITEM* net : netInfoList )
{ {
const int& netCode = net->GetNetCode(); const int& netCode = net->GetNetCode();
const wxString& netName = getUnescapedNetName( net ); const wxString& netName = getUnescapedNetName( net );
@ -416,6 +406,8 @@ void DIALOG_COPPER_ZONE::buildListOfNets( const NETINFO_LIST& nets )
m_maxNetCode = std::max( netCode, m_maxNetCode ); m_maxNetCode = std::max( netCode, m_maxNetCode );
} }
} }
updateDisplayedListOfNets();
} }
@ -624,7 +616,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly )
void DIALOG_COPPER_ZONE::updateCurrentNetSelection() void DIALOG_COPPER_ZONE::updateCurrentNetSelection()
{ {
const int netSelection{ m_ListNetNameSelection->GetSelection() }; const int netSelection = m_ListNetNameSelection->GetSelection();
if( netSelection > 0 ) if( netSelection > 0 )
{ {
@ -675,17 +667,13 @@ void DIALOG_COPPER_ZONE::storePersistentNetSortConfigurations()
{ {
// These configurations are persistent across multiple invocations of // These configurations are persistent across multiple invocations of
// this dialog // this dialog
int newConfig{ NO_PERSISTENT_SORT_MODE }; int newConfig = NO_PERSISTENT_SORT_MODE;
if( m_hideAutoGeneratedNets ) if( m_hideAutoGeneratedNets )
{
newConfig |= HIDE_ANONYMOUS_NETS; newConfig |= HIDE_ANONYMOUS_NETS;
}
if( m_netSortingByPadCount ) if( m_netSortingByPadCount )
{
newConfig |= SORT_BY_PAD_COUNT; newConfig |= SORT_BY_PAD_COUNT;
}
PCBNEW_SETTINGS* cfg = m_Parent->GetPcbNewSettings(); PCBNEW_SETTINGS* cfg = m_Parent->GetPcbNewSettings();
cfg->m_Zones.net_sort_mode = newConfig; cfg->m_Zones.net_sort_mode = newConfig;
@ -694,16 +682,14 @@ void DIALOG_COPPER_ZONE::storePersistentNetSortConfigurations()
void DIALOG_COPPER_ZONE::loadPersistentNetSortConfigurations() void DIALOG_COPPER_ZONE::loadPersistentNetSortConfigurations()
{ {
PCBNEW_SETTINGS* cfg{ m_Parent->GetPcbNewSettings() }; PCBNEW_SETTINGS* cfg = m_Parent->GetPcbNewSettings();
int savedConfig{ cfg->m_Zones.net_sort_mode }; int sortMode = cfg->m_Zones.net_sort_mode;
if( savedConfig == DEFAULT_SORT_CONFIG ) if( sortMode == DEFAULT_SORT_CONFIG )
{ sortMode = HIDE_ANONYMOUS_NETS;
savedConfig = HIDE_ANONYMOUS_NETS;
}
m_hideAutoGeneratedNets = ( savedConfig & HIDE_ANONYMOUS_NETS ); m_hideAutoGeneratedNets = ( sortMode & HIDE_ANONYMOUS_NETS );
m_netSortingByPadCount = ( savedConfig & SORT_BY_PAD_COUNT ); m_netSortingByPadCount = ( sortMode & SORT_BY_PAD_COUNT );
} }
@ -919,6 +905,7 @@ void DIALOG_COPPER_ZONE::displayNetsList( const wxArrayString& netNamesList, int
int DIALOG_COPPER_ZONE::ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList ) int DIALOG_COPPER_ZONE::ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList )
{ {
int selectedIndex = 0; int selectedIndex = 0;
if( selectedNetCode > INVALID_NET_CODE ) if( selectedNetCode > INVALID_NET_CODE )
{ {
NETINFO_ITEM* selectedNet = m_Parent->GetBoard()->FindNet( selectedNetCode ); NETINFO_ITEM* selectedNet = m_Parent->GetBoard()->FindNet( selectedNetCode );