Use correct project name when adding new symbol instances.
When adding a sheet using a schematic from another project, set the project name for the new symbol instance data to the current project rather than the project name from the copied instance data.
This commit is contained in:
parent
b1dcd7ecf8
commit
5d99aaf0a4
|
@ -640,7 +640,7 @@ bool DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged( const wxString& aNewFilena
|
|||
|
||||
SCH_SHEET_LIST sheetHierarchy( m_sheet ); // The hierarchy of the loaded file.
|
||||
|
||||
sheetHierarchy.AddNewSymbolInstances( currentSheet );
|
||||
sheetHierarchy.AddNewSymbolInstances( currentSheet, m_frame->Prj().GetProjectName() );
|
||||
sheetHierarchy.AddNewSheetInstances( currentSheet,
|
||||
fullHierarchy.GetLastVirtualPageNumber() );
|
||||
}
|
||||
|
|
|
@ -551,8 +551,11 @@ void SCH_SHEET_PATH::SetPageNumber( const wxString& aPageNumber )
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET_PATH::AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath )
|
||||
void SCH_SHEET_PATH::AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath,
|
||||
const wxString& aProjectName )
|
||||
{
|
||||
wxCHECK( !aProjectName.IsEmpty(), /* void */ );
|
||||
|
||||
SCH_SHEET_PATH newSheetPath( aPrefixSheetPath );
|
||||
SCH_SHEET_PATH currentSheetPath( *this );
|
||||
|
||||
|
@ -569,12 +572,16 @@ void SCH_SHEET_PATH::AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPa
|
|||
|
||||
if( symbol->GetInstance( newSymbolInstance, Path(), true ) )
|
||||
{
|
||||
newSymbolInstance.m_ProjectName = aProjectName;
|
||||
// Use an existing symbol instance for this path if it exists.
|
||||
|
||||
newSymbolInstance.m_Path = newSheetPath.Path();
|
||||
symbol->AddHierarchicalReference( newSymbolInstance );
|
||||
}
|
||||
else if( !symbol->GetInstances().empty() )
|
||||
{
|
||||
newSymbolInstance.m_ProjectName = aProjectName;
|
||||
|
||||
// Use the first symbol instance if any symbol instance data exists.
|
||||
newSymbolInstance = symbol->GetInstances()[0];
|
||||
newSymbolInstance.m_Path = newSheetPath.Path();
|
||||
|
@ -582,6 +589,8 @@ void SCH_SHEET_PATH::AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPa
|
|||
}
|
||||
else
|
||||
{
|
||||
newSymbolInstance.m_ProjectName = aProjectName;
|
||||
|
||||
// Fall back to the last saved symbol field and unit settings if there is no
|
||||
// instance data.
|
||||
newSymbolInstance.m_Path = newSheetPath.Path();
|
||||
|
@ -1226,10 +1235,11 @@ void SCH_SHEET_LIST::SetInitialPageNumbers()
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET_LIST::AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath )
|
||||
void SCH_SHEET_LIST::AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath,
|
||||
const wxString& aProjectName )
|
||||
{
|
||||
for( SCH_SHEET_PATH& sheetPath : *this )
|
||||
sheetPath.AddNewSymbolInstances( aPrefixSheetPath );
|
||||
sheetPath.AddNewSymbolInstances( aPrefixSheetPath, aProjectName );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -391,8 +391,13 @@ public:
|
|||
* from the library symbol.
|
||||
* - If all else fails, set the reference to "U?", the unit to 1, and everything else to
|
||||
* an empty string.
|
||||
*
|
||||
* @param aPrefixSheetPath is the sheet path to prefix to this sheet path for the new symbol
|
||||
* instance.
|
||||
* @param aProjectName is the name of the project for the new symbol instance data.
|
||||
*/
|
||||
void AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath );
|
||||
void AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath,
|
||||
const wxString& aProjectName );
|
||||
|
||||
void RemoveSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath );
|
||||
|
||||
|
@ -665,8 +670,10 @@ public:
|
|||
* with \a aPrefixSheetPath.
|
||||
*
|
||||
* @param aPrefixSheetPath is the sheet path to append the new symbol instances to.
|
||||
* @param aProjectName is the name of the project for the new symbol instance data.
|
||||
*/
|
||||
void AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath );
|
||||
void AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath,
|
||||
const wxString& aProjectName );
|
||||
|
||||
void AddNewSheetInstances( const SCH_SHEET_PATH& aPrefixSheetPath,
|
||||
int aLastVirtualPageNumber );
|
||||
|
|
|
@ -570,7 +570,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr
|
|||
newScreen->MigrateSimModels();
|
||||
|
||||
// Attempt to create new symbol instances using the instance data loaded above.
|
||||
sheetHierarchy.AddNewSymbolInstances( *aCurrentSheet );
|
||||
sheetHierarchy.AddNewSymbolInstances( *aCurrentSheet, Prj().GetProjectName() );
|
||||
|
||||
// Add new sheet instance data.
|
||||
sheetHierarchy.AddNewSheetInstances( *aCurrentSheet, hierarchy.GetLastVirtualPageNumber() );
|
||||
|
|
Loading…
Reference in New Issue