Don't crash when failing to deserialize old exclusions
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4820
This commit is contained in:
parent
db4502e2ae
commit
2a1550d1d2
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue