Fix crash in SCH_LABEL_BASE::IsType() when the item is not living in a schematic.

It happens for instance when copying the item from the clipboard.
From master branch.
Fixes #11128
This commit is contained in:
jean-pierre charras 2022-03-14 09:36:10 +01:00
parent af4a4cbc08
commit 6f6505f6a1
1 changed files with 5 additions and 0 deletions

View File

@ -861,6 +861,11 @@ bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const
wxCHECK_MSG( Schematic(), false, wxT( "No parent SCHEMATIC set for SCH_LABEL!" ) ); wxCHECK_MSG( Schematic(), false, wxT( "No parent SCHEMATIC set for SCH_LABEL!" ) );
// Ensure m_connected_items for Schematic()->CurrentSheet() exists.
// Can be not the case when "this" is living in clipboard
if( m_connected_items.find( Schematic()->CurrentSheet() ) == m_connected_items.end() )
return false;
const SCH_ITEM_SET& item_set = m_connected_items.at( Schematic()->CurrentSheet() ); const SCH_ITEM_SET& item_set = m_connected_items.at( Schematic()->CurrentSheet() );
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p ) for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )