Don't crash when failing to deserialize old exclusions

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4820
This commit is contained in:
Jon Evans 2020-07-06 12:53:55 -04:00
parent db4502e2ae
commit 2a1550d1d2
3 changed files with 11 additions and 3 deletions

View File

@ -77,6 +77,10 @@ MARKER_PCB* MARKER_PCB::Deserialize( const wxString& data )
(int) strtol( props[2].c_str(), nullptr, 10 ) );
DRC_ITEM* drcItem = DRC_ITEM::Create( props[0] );
if( !drcItem )
return nullptr;
drcItem->SetItems( KIID( props[3] ), KIID( props[4] ) );
return new MARKER_PCB( drcItem, markerPos );

View File

@ -244,7 +244,7 @@ DRC_ITEM* DRC_ITEM::Create( const wxString& aErrorKey )
return new DRC_ITEM( static_cast<const DRC_ITEM&>( item ) );
}
wxFAIL_MSG( "Unknown DRC settings key: " + aErrorKey );
// This can happen if a project has old-format exclusions. Just drop these items.
return nullptr;
}

View File

@ -531,8 +531,12 @@ void PCB_EDIT_FRAME::ResolveDRCExclusions()
for( const wxString& exclusionData : bds.m_DrcExclusions )
{
MARKER_PCB* marker = MARKER_PCB::Deserialize( exclusionData );
marker->SetExcluded( true );
commit.Add( marker );
if( marker )
{
marker->SetExcluded( true );
commit.Add( marker );
}
}
bds.m_DrcExclusions.clear();