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.
This commit is contained in:
Wayne Stambaugh 2024-04-18 15:47:34 -04:00
parent 2ca8abd7f1
commit 17bcc27ff6
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

@ -2031,29 +2031,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::DrawTable( const TOOL_EVENT& aEvent )
{
SCHEMATIC* schematic = getModel<SCHEMATIC>();
@ -2430,7 +2407,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

@ -75,8 +75,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;