Fix several library symbol multiple inheritance issues.
This commit is contained in:
parent
581cc0de5c
commit
5e86ba1abe
|
@ -639,7 +639,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
|
||||||
|
|
||||||
// If the field isn't defined then inherit the parent field value.
|
// If the field isn't defined then inherit the parent field value.
|
||||||
if( tmp.IsEmpty() )
|
if( tmp.IsEmpty() )
|
||||||
retv->GetFieldById( i )->SetText( parent->GetFieldById( i )->GetText() );
|
retv->GetFieldById( i )->SetText( retv->GetFieldById( i )->GetText() );
|
||||||
else
|
else
|
||||||
*retv->GetFieldById( i ) = *GetFieldById( i );
|
*retv->GetFieldById( i ) = *GetFieldById( i );
|
||||||
}
|
}
|
||||||
|
@ -714,7 +714,12 @@ const wxString LIB_SYMBOL::GetLibraryName() const
|
||||||
bool LIB_SYMBOL::IsPower() const
|
bool LIB_SYMBOL::IsPower() const
|
||||||
{
|
{
|
||||||
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
||||||
return parent->m_options == ENTRY_POWER;
|
{
|
||||||
|
if( parent->IsRoot() )
|
||||||
|
return parent->m_options == ENTRY_POWER;
|
||||||
|
else
|
||||||
|
return parent->IsPower();
|
||||||
|
}
|
||||||
|
|
||||||
return m_options == ENTRY_POWER;
|
return m_options == ENTRY_POWER;
|
||||||
}
|
}
|
||||||
|
@ -723,7 +728,12 @@ bool LIB_SYMBOL::IsPower() const
|
||||||
void LIB_SYMBOL::SetPower()
|
void LIB_SYMBOL::SetPower()
|
||||||
{
|
{
|
||||||
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
||||||
parent->m_options = ENTRY_POWER;
|
{
|
||||||
|
if( parent->IsRoot() )
|
||||||
|
parent->m_options = ENTRY_POWER;
|
||||||
|
else
|
||||||
|
parent->SetPower();
|
||||||
|
}
|
||||||
|
|
||||||
m_options = ENTRY_POWER;
|
m_options = ENTRY_POWER;
|
||||||
}
|
}
|
||||||
|
@ -732,7 +742,12 @@ void LIB_SYMBOL::SetPower()
|
||||||
bool LIB_SYMBOL::IsNormal() const
|
bool LIB_SYMBOL::IsNormal() const
|
||||||
{
|
{
|
||||||
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
||||||
return parent->m_options == ENTRY_NORMAL;
|
{
|
||||||
|
if( parent->IsRoot() )
|
||||||
|
return parent->m_options == ENTRY_NORMAL;
|
||||||
|
else
|
||||||
|
return parent->IsNormal();
|
||||||
|
}
|
||||||
|
|
||||||
return m_options == ENTRY_NORMAL;
|
return m_options == ENTRY_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -741,7 +756,12 @@ bool LIB_SYMBOL::IsNormal() const
|
||||||
void LIB_SYMBOL::SetNormal()
|
void LIB_SYMBOL::SetNormal()
|
||||||
{
|
{
|
||||||
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
||||||
parent->m_options = ENTRY_NORMAL;
|
{
|
||||||
|
if( parent->IsRoot() )
|
||||||
|
parent->m_options = ENTRY_NORMAL;
|
||||||
|
else
|
||||||
|
parent->SetNormal();
|
||||||
|
}
|
||||||
|
|
||||||
m_options = ENTRY_NORMAL;
|
m_options = ENTRY_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,26 +626,32 @@ BOOST_AUTO_TEST_CASE( Inheritance )
|
||||||
BOOST_CHECK_EQUAL( child->GetUnitCount(), 4 );
|
BOOST_CHECK_EQUAL( child->GetUnitCount(), 4 );
|
||||||
parent->SetUnitCount( 1 );
|
parent->SetUnitCount( 1 );
|
||||||
|
|
||||||
LIB_FIELD* field = new LIB_FIELD( MANDATORY_FIELDS, "Manufacturer" );
|
parent->GetDatasheetField().SetText( "https://kicad/resistors.pdf" );
|
||||||
field->SetText( "Manufacturer" );
|
ref->GetDatasheetField().SetText( "https://kicad/resistors.pdf" );
|
||||||
child->AddField( field );
|
|
||||||
|
BOOST_CHECK( *parent == *ref );
|
||||||
|
|
||||||
ref->SetName( "child" );
|
ref->SetName( "child" );
|
||||||
|
LIB_FIELD* field = new LIB_FIELD( MANDATORY_FIELDS, "Manufacturer" );
|
||||||
|
field->SetText( "KiCad" );
|
||||||
|
child->AddField( field );
|
||||||
field = new LIB_FIELD( MANDATORY_FIELDS, "Manufacturer" );
|
field = new LIB_FIELD( MANDATORY_FIELDS, "Manufacturer" );
|
||||||
field->SetText( "Manufacturer" );
|
field->SetText( "KiCad" );
|
||||||
ref->AddField( field );
|
ref->AddField( field );
|
||||||
BOOST_CHECK( *ref == *child->Flatten() );
|
BOOST_CHECK( *ref == *child->Flatten() );
|
||||||
|
|
||||||
ref->SetName( "grandchild" );
|
ref->SetName( "grandchild" );
|
||||||
field = new LIB_FIELD( MANDATORY_FIELDS + 1, "MPN" );
|
field = new LIB_FIELD( MANDATORY_FIELDS + 1, "MPN" );
|
||||||
field->SetText( "123456" );
|
field->SetText( "123456" );
|
||||||
ref->AddField( field );
|
grandChild->AddField( field );
|
||||||
|
|
||||||
field = new LIB_FIELD( MANDATORY_FIELDS + 1, "MPN" );
|
field = new LIB_FIELD( MANDATORY_FIELDS + 1, "MPN" );
|
||||||
field->SetText( "123456" );
|
field->SetText( "123456" );
|
||||||
grandChild->AddField( field );
|
ref->AddField( field );
|
||||||
BOOST_CHECK( *ref == *grandChild->Flatten() );
|
BOOST_CHECK( *ref == *grandChild->Flatten() );
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL( grandChild->Flatten()->GetDatasheetField().GetText(),
|
||||||
|
"https://kicad/resistors.pdf" );
|
||||||
|
|
||||||
child->SetParent();
|
child->SetParent();
|
||||||
BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 );
|
BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue