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.
Fixes #11128
https://gitlab.com/kicad/code/kicad/issues/11128
This commit is contained in:
jean-pierre charras 2022-03-14 09:23:16 +01:00
parent 605dd8a580
commit 2cb719f0cf
1 changed files with 5 additions and 0 deletions

View File

@ -221,6 +221,11 @@ bool SCH_LABEL_BASE::IsType( const KICAD_T aScanTypes[] ) const
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() );
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )