Don't re-use FieldIDs when assigning ids on save.
Fixes https://gitlab.com/kicad/code/kicad/issues/7849
This commit is contained in:
parent
d160b30ff1
commit
2a9186d9e9
|
@ -384,7 +384,7 @@ void SCH_SEXPR_PLUGIN::init( SCHEMATIC* aSchematic, const PROPERTIES* aPropertie
|
||||||
m_schematic = aSchematic;
|
m_schematic = aSchematic;
|
||||||
m_cache = nullptr;
|
m_cache = nullptr;
|
||||||
m_out = nullptr;
|
m_out = nullptr;
|
||||||
m_fieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS
|
m_nextFreeFieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_SHEET* SCH_SEXPR_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
SCH_SHEET* SCH_SEXPR_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
||||||
|
@ -957,7 +957,7 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aShee
|
||||||
|
|
||||||
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSymbol->m_Uuid.AsString() ) );
|
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSymbol->m_Uuid.AsString() ) );
|
||||||
|
|
||||||
m_fieldId = MANDATORY_FIELDS;
|
m_nextFreeFieldId = MANDATORY_FIELDS;
|
||||||
|
|
||||||
for( SCH_FIELD& field : aSymbol->GetFields() )
|
for( SCH_FIELD& field : aSymbol->GetFields() )
|
||||||
{
|
{
|
||||||
|
@ -1006,8 +1006,12 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel )
|
||||||
|
|
||||||
if( aField->GetId() == -1 /* undefined ID */ )
|
if( aField->GetId() == -1 /* undefined ID */ )
|
||||||
{
|
{
|
||||||
aField->SetId( m_fieldId );
|
aField->SetId( m_nextFreeFieldId );
|
||||||
m_fieldId += 1;
|
m_nextFreeFieldId += 1;
|
||||||
|
}
|
||||||
|
else if( aField->GetId() >= m_nextFreeFieldId )
|
||||||
|
{
|
||||||
|
m_nextFreeFieldId = aField->GetId() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_out->Print( aNestLevel, "(property %s %s (id %d) (at %s %s %s)",
|
m_out->Print( aNestLevel, "(property %s %s (id %d) (at %s %s %s)",
|
||||||
|
@ -1106,7 +1110,7 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel )
|
||||||
|
|
||||||
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSheet->m_Uuid.AsString() ) );
|
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSheet->m_Uuid.AsString() ) );
|
||||||
|
|
||||||
m_fieldId = SHEET_MANDATORY_FIELDS;
|
m_nextFreeFieldId = SHEET_MANDATORY_FIELDS;
|
||||||
|
|
||||||
for( SCH_FIELD& field : aSheet->GetFields() )
|
for( SCH_FIELD& field : aSheet->GetFields() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -147,10 +147,9 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_version; ///< Version of file being loaded.
|
int m_version; ///< Version of file being loaded.
|
||||||
int m_fieldId; ///< Non-mandatory schematic field ID counter.
|
int m_nextFreeFieldId;
|
||||||
|
|
||||||
/** For throwing exceptions or errors on partial schematic loads. */
|
wxString m_error; ///< For throwing exceptions or errors on partial loads.
|
||||||
wxString m_error;
|
|
||||||
|
|
||||||
wxString m_path; ///< Root project path for loading child sheets.
|
wxString m_path; ///< Root project path for loading child sheets.
|
||||||
std::stack<wxString> m_currentPath;///< Stack to maintain nested sheet paths
|
std::stack<wxString> m_currentPath;///< Stack to maintain nested sheet paths
|
||||||
|
|
Loading…
Reference in New Issue