Fix missing instance data when reusing an already loaded schematic.

Remove duplicate sheet instance page numbering.  It's already done when
the sheet is loaded from an exiting file or an already loaded schematic.
Remove the unnecessary page update code from the drawing tool.

(cherry picked from commit 17bcc27ff6)
This commit is contained in:
Wayne Stambaugh 2024-04-18 15:47:34 -04:00
parent 9e5876df5c
commit 8d62a5fd3f
3 changed files with 6 additions and 26 deletions

View File

@ -637,6 +637,12 @@ bool DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged( const wxString& aNewFilena
// It's safe to set the sheet screen now.
m_sheet->SetScreen( useScreen );
SCH_SHEET_LIST sheetHierarchy( m_sheet ); // The hierarchy of the loaded file.
sheetHierarchy.AddNewSymbolInstances( currentSheet );
sheetHierarchy.AddNewSheetInstances( currentSheet,
fullHierarchy.GetLastVirtualPageNumber() );
}
else if( loadFromFile )
{

View File

@ -2002,29 +2002,6 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
}
void SCH_DRAWING_TOOLS::initSharedInstancePageNumbers( const SCH_SHEET_PATH& aAddedSheet )
{
SCH_SHEET_LIST fullHierarchy = m_frame->Schematic().GetFullHierarchy();
SCH_SHEET_LIST instances = fullHierarchy.FindAllSheetsForScreen( aAddedSheet.LastScreen() );
long pageNo;
long addedSheetPageNo;
if( aAddedSheet.GetPageNumber().ToLong( &addedSheetPageNo ) )
pageNo = addedSheetPageNo + 1;
else
pageNo = (signed)( fullHierarchy.size() - instances.size() + 1 );
for( SCH_SHEET_PATH& sheet : instances )
{
if( sheet == aAddedSheet )
continue;
sheet.SetPageNumber( wxString::Format( wxS( "%ld" ), pageNo++ ) );
}
}
int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
{
SCH_SHEET* sheet = nullptr;
@ -2184,7 +2161,6 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
SCH_SHEET_PATH newPath = m_frame->GetCurrentSheet();
newPath.push_back( sheet );
initSharedInstancePageNumbers( newPath );
m_frame->UpdateHierarchyNavigator();
m_selectionTool->AddItemToSel( sheet );

View File

@ -69,8 +69,6 @@ private:
void sizeSheet( SCH_SHEET* aSheet, const VECTOR2I& aPos );
void initSharedInstancePageNumbers( const SCH_SHEET_PATH& aAddedSheet );
///< Set up handlers for various events.
void setTransitions() override;