Fix missing legacy value and footprint field instance data.
The legacy and s-expression (prior to version 20200828) file formats only supported symbol unit and reference fields so the newly added value and footprint fields must be updated from the original symbol fields. Fixes https://gitlab.com/kicad/code/kicad/-/issues/12226
This commit is contained in:
parent
19e27ef587
commit
797827b833
|
@ -428,6 +428,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
// Legacy schematic can have duplicate time stamps so fix that before converting
|
||||
// to the s-expression format.
|
||||
schematic.ReplaceDuplicateTimeStamps();
|
||||
schematic.SetLegacySymbolInstanceData();
|
||||
|
||||
// Allow the schematic to be saved to new file format without making any edits.
|
||||
OnModify();
|
||||
|
|
|
@ -2297,14 +2297,18 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly,
|
|||
// polyline keyword is used in eeschema both for SCH_SHAPE and SCH_LINE items.
|
||||
// In symbols it describes a polygon, having n corners and can be filled
|
||||
// In schematic it describes a line (with no fill descr), but could be extended to a
|
||||
// polygon (for instance when importing files) because the schematic handles all SCH_SHAPE.
|
||||
// polygon (for instance when importing files) because the schematic handles all
|
||||
// SCH_SHAPE.
|
||||
|
||||
// parseSchPolyLine() returns always a SCH_SHAPE, io convert it to a simple SCH_LINE
|
||||
// For compatibility reasons, keep SCH_SHAPE for a polygon and convert to SCH_LINE
|
||||
// when the item has only 2 corners, similar to a SCH_LINE
|
||||
SCH_SHAPE* poly = parseSchPolyLine();
|
||||
|
||||
if( poly->GetPointCount() > 2 )
|
||||
{
|
||||
screen->Append( poly );
|
||||
}
|
||||
else
|
||||
{
|
||||
// For SCH_SHAPE having only 2 points, this is a "old" SCH_LINE entity.
|
||||
|
@ -2382,6 +2386,9 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly,
|
|||
}
|
||||
|
||||
screen->UpdateLocalLibSymbolLinks();
|
||||
|
||||
if( m_requiredVersion < 20200828 )
|
||||
screen->SetLegacySymbolInstanceData();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1204,7 +1204,6 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader )
|
|||
|
||||
symbol->AddHierarchicalReference( path, reference, (int)tmp );
|
||||
symbol->GetField( REFERENCE_FIELD )->SetText( reference );
|
||||
|
||||
}
|
||||
else if( strCompare( "F", line, &line ) )
|
||||
{
|
||||
|
|
|
@ -1431,6 +1431,24 @@ void SCH_SCREEN::AddBusAlias( std::shared_ptr<BUS_ALIAS> aAlias )
|
|||
}
|
||||
|
||||
|
||||
void SCH_SCREEN::SetLegacySymbolInstanceData()
|
||||
{
|
||||
for( SCH_ITEM* item : Items().OfType( SCH_SYMBOL_T ) )
|
||||
{
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
||||
|
||||
// Add missing value and footprint instance data for legacy schematics.
|
||||
for( const SYMBOL_INSTANCE_REFERENCE& instance : symbol->GetInstanceReferences() )
|
||||
{
|
||||
symbol->AddHierarchicalReference( instance.m_Path, instance.m_Reference,
|
||||
instance.m_Unit,
|
||||
symbol->GetField( VALUE_FIELD )->GetText(),
|
||||
symbol->GetField( FOOTPRINT_FIELD )->GetText() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
|
||||
{
|
||||
|
@ -1821,3 +1839,11 @@ void SCH_SCREENS::BuildClientSheetPathList()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_SCREENS::SetLegacySymbolInstanceData()
|
||||
{
|
||||
|
||||
for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
|
||||
screen->SetLegacySymbolInstanceData();
|
||||
}
|
||||
|
|
|
@ -498,6 +498,11 @@ public:
|
|||
|
||||
void AssignNewUuid() { m_uuid = KIID(); }
|
||||
|
||||
/**
|
||||
* Update the symbol value and footprint instance data for legacy designs.
|
||||
*/
|
||||
void SetLegacySymbolInstanceData();
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const override;
|
||||
#endif
|
||||
|
@ -716,6 +721,11 @@ public:
|
|||
*/
|
||||
bool CanCauseCaseSensitivityIssue( const wxString& aSchematicFileName ) const;
|
||||
|
||||
/**
|
||||
* Update the symbol value and footprint instance data for legacy designs.
|
||||
*/
|
||||
void SetLegacySymbolInstanceData();
|
||||
|
||||
private:
|
||||
void addScreenToList( SCH_SCREEN* aScreen, SCH_SHEET* aSheet );
|
||||
void buildScreenList( SCH_SHEET* aSheet);
|
||||
|
|
|
@ -543,7 +543,8 @@ void SCH_SYMBOL::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
|
|||
}
|
||||
|
||||
if( !found )
|
||||
AddHierarchicalReference( path, ref, m_unit );
|
||||
AddHierarchicalReference( path, ref, m_unit, GetField( VALUE_FIELD )->GetText(),
|
||||
GetField( FOOTPRINT_FIELD )->GetText() );
|
||||
|
||||
for( std::unique_ptr<SCH_PIN>& pin : m_pins )
|
||||
pin->ClearDefaultNetName( sheet );
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -417,3 +417,11 @@ SCH_SHEET_LIST& SCHEMATIC::GetFullHierarchy() const
|
|||
|
||||
return hierarchy;
|
||||
}
|
||||
|
||||
|
||||
void SCHEMATIC::SetLegacySymbolInstanceData()
|
||||
{
|
||||
SCH_SCREENS screens( m_rootSheet );
|
||||
|
||||
screens.SetLegacySymbolInstanceData();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -169,6 +169,14 @@ public:
|
|||
*/
|
||||
SCH_SHEET_LIST& GetFullHierarchy() const;
|
||||
|
||||
/**
|
||||
* Update the symbol value and footprint instance data for legacy designs.
|
||||
*
|
||||
* Prior to schematic file format version 20200828 and legacy file format version, only
|
||||
* symbol reference field and unit were saved in the instance data. The value and footprint
|
||||
* fields must be carried forward from the original symbol to prevent data loss.
|
||||
*/
|
||||
void SetLegacySymbolInstanceData();
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const override {}
|
||||
|
|
Loading…
Reference in New Issue