From cc47082566c11b9a482609d33f4714ea5c9cfeaf Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 23 May 2020 15:11:02 -0400 Subject: [PATCH] Reset connection graph when loading new root sheet --- eeschema/schematic.cpp | 10 ++++++++++ eeschema/schematic.h | 11 +++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/eeschema/schematic.cpp b/eeschema/schematic.cpp index f6a752650b..a9e4e39fe3 100644 --- a/eeschema/schematic.cpp +++ b/eeschema/schematic.cpp @@ -55,6 +55,16 @@ void SCHEMATIC::Reset() } +void SCHEMATIC::SetRoot( SCH_SHEET* aRootSheet ) +{ + wxCHECK_RET( aRootSheet, "Call to SetRoot with null SCH_SHEET!" ); + + m_rootSheet = aRootSheet; + + m_connectionGraph->Reset(); +} + + SCH_SCREEN* SCHEMATIC::RootScreen() const { return IsValid() ? m_rootSheet->GetScreen() : nullptr; diff --git a/eeschema/schematic.h b/eeschema/schematic.h index fa970e1a1c..1799ce7d67 100644 --- a/eeschema/schematic.h +++ b/eeschema/schematic.h @@ -106,10 +106,13 @@ public: return *m_rootSheet; } - void SetRoot( SCH_SHEET* aRootSheet ) - { - m_rootSheet = aRootSheet; - } + /** + * Initializes the schematic with a new root sheet. + * This is typically done by calling a file loader that returns the new root sheet + * As a side-effect, takes care of some post-load initialization. + * @param aRootSheet is the new root sheet for this schematic. + */ + void SetRoot( SCH_SHEET* aRootSheet ); /// A simple test if the schematic is loaded, not a complete one bool IsValid() const