From f8a25d20f80badbbb4111aa2e55a98d57f8158f2 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 18 Apr 2024 10:46:24 -0700 Subject: [PATCH] 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 --- eeschema/eeschema_helpers.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/eeschema/eeschema_helpers.cpp b/eeschema/eeschema_helpers.cpp index 41a40205e4..7365e09de8 100644 --- a/eeschema/eeschema_helpers.cpp +++ b/eeschema/eeschema_helpers.cpp @@ -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( 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();