Fix crash when switching schematics

When switching schematics that causes an error message (for example if
the schematic needs repair), wx can refresh in between view updates,
leading to a null preview.
This commit is contained in:
Seth Hillbrand 2021-02-16 10:08:31 -08:00
parent 015c4d5779
commit df573255e0
1 changed files with 8 additions and 5 deletions

View File

@ -1529,13 +1529,16 @@ std::shared_ptr<VIEW_OVERLAY> VIEW::MakeOverlay()
void VIEW::ClearPreview()
{
m_preview->Clear();
if( !m_preview )
return;
for( EDA_ITEM* item : m_ownedItems )
delete item;
m_preview->Clear();
m_ownedItems.clear();
Update( m_preview.get() );
for( EDA_ITEM *item : m_ownedItems )
delete item;
m_ownedItems.clear();
Update( m_preview.get() );
}