mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +02:00
Fix usage of PCB_FIELD( PCB_TEXT& )
Passing a pointer to the CTOR invokes the PCB_FIELD( BOARD_ITEM* ) ctor, which is not what is intended. Passing just the reference is better but still ends up creating a PCB_FIELD class with type PCB_TEXT because it didn't correctly set the type. So we need to properly set our type and our parent, then copy the text attributes over. We can't use the default copy operator because this also copies the struct_id of PCB_TEXT Fixes https://gitlab.com/kicad/code/kicad/-/issues/20875
This commit is contained in:
parent
c2c987f9c0
commit
750dbe6336
@ -43,11 +43,17 @@ PCB_FIELD::PCB_FIELD( FOOTPRINT* aParent, FIELD_T aFieldId, const wxString& aNam
|
||||
|
||||
|
||||
PCB_FIELD::PCB_FIELD( const PCB_TEXT& aText, FIELD_T aFieldId, const wxString& aName ) :
|
||||
PCB_TEXT( aText ),
|
||||
PCB_TEXT( aText.GetParent(), PCB_FIELD_T ),
|
||||
m_id( aFieldId ),
|
||||
m_ordinal( static_cast<int>( aFieldId ) ),
|
||||
m_name( aName )
|
||||
{
|
||||
// Copy the text properties from the PCB_TEXT
|
||||
SetText( aText.GetText() );
|
||||
SetVisible( aText.IsVisible() );
|
||||
SetLayer( aText.GetLayer() );
|
||||
SetPosition( aText.GetPosition() );
|
||||
SetAttributes( aText.GetAttributes() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -2593,7 +2593,7 @@ bool FABMASTER::loadFootprints( BOARD* aBoard )
|
||||
// should be hidden by default to prevent clutter.
|
||||
if( txt->GetLayer() != F_SilkS && txt->GetLayer() != B_SilkS )
|
||||
{
|
||||
PCB_FIELD* field = new PCB_FIELD( txt.get(), FIELD_T::USER );
|
||||
PCB_FIELD* field = new PCB_FIELD( *txt, FIELD_T::USER );
|
||||
field->SetVisible( false );
|
||||
fp->Add( field, ADD_MODE::APPEND );
|
||||
}
|
||||
|
@ -1245,7 +1245,7 @@ void PCB_IO_KICAD_LEGACY::loadFOOTPRINT( FOOTPRINT* aFootprint )
|
||||
if( !text->IsVisible() && text->Type() == PCB_TEXT_T )
|
||||
{
|
||||
aFootprint->Remove( text );
|
||||
aFootprint->Add( new PCB_FIELD( text, FIELD_T::USER ) );
|
||||
aFootprint->Add( new PCB_FIELD( *text, FIELD_T::USER ) );
|
||||
delete text;
|
||||
}
|
||||
}
|
||||
|
@ -3461,7 +3461,7 @@ PCB_TEXT* PCB_IO_KICAD_SEXPR_PARSER::parsePCB_TEXT( BOARD_ITEM* aParent, PCB_TEX
|
||||
{
|
||||
// Convert hidden footprint text (which is no longer supported) into a hidden field
|
||||
if( !text->IsVisible() && text->Type() == PCB_TEXT_T )
|
||||
return new PCB_FIELD( text.get(), FIELD_T::USER );
|
||||
return new PCB_FIELD( *text.get(), FIELD_T::USER );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user