Remember to set the root sheet before loading

This is done in the frame for GUI loading so we need to explicitly set
this when loading files in the cli

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17790
This commit is contained in:
Seth Hillbrand 2024-04-18 10:46:24 -07:00
parent 8d1b1598db
commit f8a25d20f8
1 changed files with 13 additions and 0 deletions

View File

@ -126,6 +126,19 @@ SCHEMATIC* EESCHEMA_HELPERS::LoadSchematic( wxString& aFileName, SCH_IO_MGR::SCH
SCHEMATIC* schematic = new SCHEMATIC( project );
SCH_SHEET* rootSheet = new SCH_SHEET( schematic );
schematic->SetRoot( rootSheet );
SCH_SCREEN* rootScreen = new SCH_SCREEN( schematic );
const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
schematic->Root().SetScreen( rootScreen );
schematic->RootScreen()->SetFileName( wxEmptyString );
// Don't leave root page number empty
schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
wxFileName schFile = aFileName;
schFile.MakeAbsolute();