EEschema: fix crash when repeat an item (ins key), due to a null parent

A recent change set the parent member of a item put in the repeat list to
nullptr (this is OK) but the code to copy an item from this list did not
update this parent member.
This commit is contained in:
jean-pierre charras 2024-08-31 18:04:41 +02:00
parent 87cf37c847
commit 8f348820f3

View File

@ -1418,6 +1418,10 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
bool restore_state = false;
// Ensure newItem has a suitable parent: the current screen, because an item from
// a list of items to repeat must be attached to this current screen
newItem->SetParent( m_frame->GetScreen() );
if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( newItem ) )
{
// If incrementing tries to go below zero, tell user why the value is repeated