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