pcbnew: intermittent fix for crash on save after undoing board update.

This commit is contained in:
Tomasz Włostowski 2018-09-23 19:21:16 +02:00
parent f3c6e1fb62
commit f16f0fc215
3 changed files with 41 additions and 2 deletions

View File

@ -3020,3 +3020,38 @@ void BOARD::ClearAllNetCodes()
for( auto track : Tracks() )
track->SetNetCode( 0 );
}
const std::vector<BOARD_CONNECTED_ITEM*> BOARD::AllConnectedItems()
{
std::vector<BOARD_CONNECTED_ITEM*> items;
for( auto track : Tracks() )
{
items.push_back( track );
}
for( auto mod : Modules() )
{
for( auto pad : mod->Pads() )
{
items.push_back( pad );
}
}
for( int i = 0; i<GetAreaCount(); i++ )
{
auto zone = GetArea( i );
items.push_back( zone );
}
return items;
}
void BOARD::SanitizeNetcodes()
{
for ( auto item : AllConnectedItems() )
{
if( FindNet( item->GetNetCode() ) == nullptr )
item->SetNetCode( NETINFO_LIST::ORPHANED );
}
}

View File

@ -254,7 +254,7 @@ public:
DLIST_ITERATOR_WRAPPER<MODULE> Modules() { return DLIST_ITERATOR_WRAPPER<MODULE>(m_Modules); }
DLIST_ITERATOR_WRAPPER<BOARD_ITEM> Drawings() { return DLIST_ITERATOR_WRAPPER<BOARD_ITEM>(m_Drawings); }
ZONE_CONTAINERS& Zones() { return m_ZoneDescriptorList; }
const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
// will be deprecated as soon as append board functionality is fixed
DLIST<BOARD_ITEM>& DrawingsList() { return m_Drawings; }
@ -1358,6 +1358,8 @@ public:
* Resets all items' netcodes to 0 (no net).
*/
void ClearAllNetCodes();
void SanitizeNetcodes();
};
#endif // CLASS_BOARD_H_

View File

@ -588,6 +588,8 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
{
Compile_Ratsnest( NULL, false );
}
GetBoard()->SanitizeNetcodes();
}