Cache full schematic sheet list sorted by sheet page number.

The sheet list is returned as a copy of the cached list rather than a
reference to prevent external code from changing the list.  While not as
performant, it eliminates the risk of the sheet list being altered in
ways that could break the schematic.  The sheet list should only be
updated by calling SCHEMATIC::RefreshHierarchy() when any appropriate
sheet changes are made.

Note to developers: there is something inherently different about how the
QA tests are loading and handling schematics versus the schematic editor.
Using the cached sheet list for the SCHEMATIC object will cause some QA
test to fail.  This is why SCHEMATIC::Hierarchy() has not replaced
SCHEMATIC::BuildSheetListSortedByPageNumbers() everywhere.
This commit is contained in:
Wayne Stambaugh
2024-10-09 09:58:50 -04:00
parent eae84fd5f3
commit a6923b3de3
44 changed files with 171 additions and 129 deletions
+3 -3
View File
@@ -53,7 +53,7 @@ bool SCH_EDIT_FRAME::CheckSheetForRecursion( SCH_SHEET* aSheet, SCH_SHEET_PATH*
wxASSERT( aSheet && aCurrentSheet );
wxString msg;
SCH_SHEET_LIST schematicSheets = Schematic().BuildUnorderedSheetList();
SCH_SHEET_LIST schematicSheets = Schematic().Hierarchy();
SCH_SHEET_LIST loadedSheets( aSheet ); // This is the schematicSheets of the loaded file.
wxString destFilePath = aCurrentSheet->LastScreen()->GetFileName();
@@ -282,7 +282,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr
}
SCH_SHEET_LIST loadedSheets( tmpSheet.get() );
SCH_SHEET_LIST schematicSheets = Schematic().BuildUnorderedSheetList();
SCH_SHEET_LIST schematicSheets = Schematic().Hierarchy();
// Make sure any new sheet changes do not cause any recursion issues.
if( !aSkipRecursionCheck && CheckSheetForRecursion( tmpSheet.get(), aCurrentSheet ) )
@@ -699,7 +699,7 @@ void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard()
bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes( const wxString& aOldName, const wxString& aSchematicFileName )
{
wxString msg;
SCH_SHEET_LIST sheets = Schematic().BuildUnorderedSheetList();
SCH_SHEET_LIST sheets = Schematic().Hierarchy();
wxFileName fn = aSchematicFileName;
wxCHECK( fn.IsAbsolute(), false );