Do not allow items to be parented to themselves.

There is code that walks up the parent chain that looks for the top most
parent.  If an object is parented to itself, this will create and infinite
loop.
This commit is contained in:
Wayne Stambaugh
2026-02-08 16:20:20 -05:00
parent 15a12b5392
commit 7de76cf7cf
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -88,6 +88,14 @@ EDA_ITEM* EDA_ITEM::findParent( KICAD_T aType ) const
}
void EDA_ITEM::SetParent( EDA_ITEM* aParent )
{
wxCHECK( aParent != this, /* void */ );
m_parent = aParent;
}
KIID EDA_ITEM::GetParentGroupId() const
{
if( EDA_GROUP* group = GetParentGroup() )
+1 -1
View File
@@ -110,7 +110,7 @@ public:
inline KICAD_T Type() const { return m_structType; }
EDA_ITEM* GetParent() const { return m_parent; }
virtual void SetParent( EDA_ITEM* aParent ) { m_parent = aParent; }
virtual void SetParent( EDA_ITEM* aParent );
virtual void SetParentGroup( EDA_GROUP* aGroup ) { m_group = aGroup; }
virtual EDA_GROUP* GetParentGroup() const { return m_group; }