Improve shared schematic file churn heuristics.
The previous solution cleared all of the fields and force the unit setting to unit one which would have less than desirable effects when reusing a schematic in another project. This solution forces all of the instance settings to the first sheet instance of the current project to prevent file change churn when changing shared sheets in the current project. This will not prevent shared schematic file changes when the first sheet instance data differs between projects.
This commit is contained in:
parent
8d05ca5982
commit
dd1dbb81f6
|
@ -685,8 +685,11 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa
|
||||||
m_out->Print( 0, ")" );
|
m_out->Print( 0, ")" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always set the unit to 1. The real symbol unit is saved in the sheet instance data.
|
int unit = ( aSymbol->GetInstanceReferences().size() == 0 ) ?
|
||||||
m_out->Print( 0, " (unit 1)" );
|
aSymbol->GetUnit() :
|
||||||
|
aSymbol->GetInstanceReferences()[0].m_Unit;
|
||||||
|
|
||||||
|
m_out->Print( 0, " (unit %d)", unit );
|
||||||
|
|
||||||
if( aSymbol->GetConvert() == LIB_ITEM::LIB_CONVERT::DEMORGAN )
|
if( aSymbol->GetConvert() == LIB_ITEM::LIB_CONVERT::DEMORGAN )
|
||||||
m_out->Print( 0, " (convert %d)", aSymbol->GetConvert() );
|
m_out->Print( 0, " (convert %d)", aSymbol->GetConvert() );
|
||||||
|
@ -710,13 +713,27 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa
|
||||||
int id = field.GetId();
|
int id = field.GetId();
|
||||||
wxString value = field.GetText();
|
wxString value = field.GetText();
|
||||||
|
|
||||||
// The reference field is always set to uninitialized and the value and footprint fields
|
// The instance fields are always set to the first sheet instance of the project to
|
||||||
// are always empty. The actual reference, value, and footprint field values are stored
|
// schematic file changes when switching sheet instances with the current project
|
||||||
// in the instance data. This prevents unwanted file change churn in shared schematics.
|
// schematic. It does not solve the problem for schematics shared between projects.
|
||||||
if( id == REFERENCE_FIELD )
|
if( id == REFERENCE_FIELD )
|
||||||
field.SetText( aSymbol->GetPrefix() + wxT( "?" ) );
|
{
|
||||||
else if( id == VALUE_FIELD || id == FOOTPRINT_FIELD )
|
field.SetText( ( aSymbol->GetInstanceReferences().size() == 0 ) ?
|
||||||
field.SetText( wxEmptyString );
|
value :
|
||||||
|
aSymbol->GetInstanceReferences()[0].m_Reference );
|
||||||
|
}
|
||||||
|
else if( id == VALUE_FIELD )
|
||||||
|
{
|
||||||
|
field.SetText( ( aSymbol->GetInstanceReferences().size() == 0 ) ?
|
||||||
|
value :
|
||||||
|
aSymbol->GetInstanceReferences()[0].m_Value );
|
||||||
|
}
|
||||||
|
else if( id == FOOTPRINT_FIELD )
|
||||||
|
{
|
||||||
|
field.SetText( ( aSymbol->GetInstanceReferences().size() == 0 ) ?
|
||||||
|
value :
|
||||||
|
aSymbol->GetInstanceReferences()[0].m_Footprint );
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -724,7 +741,7 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{
|
{
|
||||||
// Restore the changed field info on write error.
|
// Restore the changed field text on write error.
|
||||||
if( id == REFERENCE_FIELD || id == VALUE_FIELD || id == FOOTPRINT_FIELD )
|
if( id == REFERENCE_FIELD || id == VALUE_FIELD || id == FOOTPRINT_FIELD )
|
||||||
field.SetText( value );
|
field.SetText( value );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue