From 42cbcf7ef41ae643935bafeeafdca1abeb11b624 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Wed, 20 Jan 2021 23:34:10 +0000 Subject: [PATCH] Don't allow empty page numbers Fixes https://gitlab.com/kicad/code/kicad/-/issues/6698 --- eeschema/sch_edit_frame.cpp | 7 +++++++ eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index ee4f42743d..3077a8245a 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -546,6 +546,13 @@ void SCH_EDIT_FRAME::CreateScreens() m_schematic->RootScreen()->SetFileName( wxEmptyString ); + // Don't leave root page number empty + SCH_SHEET_PATH rootSheetPath; + rootSheetPath.push_back( &m_schematic->Root() ); + m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) ); + m_schematic->Root().AddInstance( rootSheetPath.Path() ); + m_schematic->Root().SetPageNumber( rootSheetPath, wxT( "1" ) ); + if( GetScreen() == NULL ) { SCH_SCREEN* screen = new SCH_SCREEN( m_schematic ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 9abf007005..95702e8daf 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -1837,6 +1837,17 @@ void SCH_SEXPR_PARSER::parseSchSheetInstances( SCH_SHEET* aRootSheet, SCH_SCREEN case T_page: NeedSYMBOL(); instance.m_PageNumber = FromUTF8(); + + // Empty page numbers are not permitted + if( instance.m_PageNumber.IsEmpty() ) + { + // Use space character instead + instance.m_PageNumber = wxT( " " ); + + // Set the file as modified so the user can be warned. + aScreen->SetModify(); + } + NeedRIGHT(); break;