From 765816ccb1268f80fd093e22bba172ac2fa2c9f4 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 4 Oct 2021 15:47:16 -0400 Subject: [PATCH] Eeschema: fix lag on network shares when duplicating and copying objects. The delay was due to recursion checks being performed every time a new SCH_SHEET_LIST object was created. The fix was to back port the optional integrity check flag added from master. It's similar to commit 63a0f537 by Jeff Young but it could not be cherry-picked due to the changes in master branch. Fixes https://gitlab.com/kicad/code/kicad/-/issues/9278 --- eeschema/block.cpp | 5 +++-- eeschema/find.cpp | 4 ++-- eeschema/plot_schematic_DXF.cpp | 4 ++-- eeschema/plot_schematic_HPGL.cpp | 4 ++-- eeschema/plot_schematic_PDF.cpp | 4 ++-- eeschema/plot_schematic_PS.cpp | 4 ++-- eeschema/plot_schematic_SVG.cpp | 6 ++--- eeschema/sch_sheet_path.cpp | 38 ++++++++++++++++++-------------- eeschema/sch_sheet_path.h | 17 +++++++------- 9 files changed, 47 insertions(+), 39 deletions(-) diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 1787671a3d..96e6c24932 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 2004-2018 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -451,7 +451,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) { unsigned i; SCH_ITEM* item; - SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the entire schematic hierarcy. + SCH_SHEET_LIST hierarchy( g_RootSheet, false ); // This is the entire schematic hierarcy. if( m_blockItems.GetCount() == 0 ) { @@ -468,6 +468,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) // the destination sheet. Moreover new sheets create new sheetpaths, and component // alternante references must be created and cleared bool hasSheetPasted = false; + // Keep trace of existing sheet paths. Paste block can modify this list SCH_SHEET_LIST initial_sheetpathList( g_RootSheet ); diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 30b41d5c3a..b1ce89a9ac 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2018 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -124,7 +124,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference, if( !aSearchHierarchy ) sheetList.push_back( *m_CurrentSheet ); else - sheetList.BuildSheetList( g_RootSheet ); + sheetList.BuildSheetList( g_RootSheet, false ); for( SCH_SHEET_PATHS_ITER it = sheetList.begin(); it != sheetList.end(); ++it ) { diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index ea7e184c30..7cd20aa4e5 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -5,7 +5,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2010 Lorenzo Marcantonio - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -50,7 +50,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) SCH_SHEET_LIST sheetList; if( aPlotAll ) - sheetList.BuildSheetList( g_RootSheet ); + sheetList.BuildSheetList( g_RootSheet, false ); else sheetList.push_back( schframe->GetCurrentSheet() ); diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index ed571a9539..1d2fd405ca 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -5,7 +5,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2010 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -96,7 +96,7 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef ) SCH_SHEET_LIST sheetList; if( aPlotAll ) - sheetList.BuildSheetList( g_RootSheet ); + sheetList.BuildSheetList( g_RootSheet, false ); else sheetList.push_back( m_parent->GetCurrentSheet() ); diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index d7bc491156..ab92d599ec 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -5,7 +5,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2010 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -53,7 +53,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) SCH_SHEET_LIST sheetList; if( aPlotAll ) - sheetList.BuildSheetList( g_RootSheet ); + sheetList.BuildSheetList( g_RootSheet, false ); else sheetList.push_back( m_parent->GetCurrentSheet() ); diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index d20e976609..f3d8aed147 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -4,7 +4,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -51,7 +51,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef ) SCH_SHEET_LIST sheetList; if( aPlotAll ) - sheetList.BuildSheetList( g_RootSheet ); + sheetList.BuildSheetList( g_RootSheet, false ); else sheetList.push_back( m_parent->GetCurrentSheet() ); diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index 6f551ca714..b54c68471a 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2011-2016 Wayne Stambaugh - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2011 Wayne Stambaugh + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -48,7 +48,7 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) SCH_SHEET_LIST sheetList; if( aPrintAll ) - sheetList.BuildSheetList( g_RootSheet ); + sheetList.BuildSheetList( g_RootSheet, false ); else sheetList.push_back( m_parent->GetCurrentSheet() ); diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 2c7c290412..0d8f340ca1 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -180,7 +180,6 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences() } - void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols, bool aForceIncludeOrphanComponents ) { @@ -423,15 +422,12 @@ SCH_SHEET* SCH_SHEET_PATH::FindSheetByName( const wxString& aSheetName ) } -/********************************************************************/ -/* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */ -/********************************************************************/ -SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet ) +SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet, bool aCheckIntegrity ) { m_isRootSheet = false; if( aSheet != NULL ) - BuildSheetList( aSheet ); + BuildSheetList( aSheet, aCheckIntegrity ); } @@ -451,7 +447,7 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheetByPath( const wxString& aPath, bool aHum } -void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) +void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet, bool aCheckIntegrity ) { wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) ); @@ -480,21 +476,30 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) { SCH_SHEET* sheet = (SCH_SHEET*) item; - if( !m_currentSheetPath.TestForRecursion( - sheet->GetFileName(), aSheet->GetFileName() ) ) - BuildSheetList( sheet ); + if( aCheckIntegrity ) + { + if( !m_currentSheetPath.TestForRecursion( sheet->GetFileName(), + aSheet->GetFileName() ) ) + BuildSheetList( sheet, true ); + else + badSheets.push_back( sheet ); + } else - badSheets.push_back( sheet ); + { + BuildSheetList( sheet, false ); + } } item = item->Next(); } - - for( auto sheet : badSheets ) + if( aCheckIntegrity ) { - aSheet->GetScreen()->Remove( sheet ); - aSheet->GetScreen()->SetModify(); + for( auto sheet : badSheets ) + { + aSheet->GetScreen()->Remove( sheet ); + aSheet->GetScreen()->SetModify(); + } } } @@ -609,6 +614,7 @@ void SCH_SHEET_LIST::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aInclu (*it).GetComponents( aReferences, aIncludePowerSymbols, aForceIncludeOrphanComponents ); } + void SCH_SHEET_LIST::GetMultiUnitComponents( SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols ) { diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 9ad30ce34d..aa8a4ec69a 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -330,12 +330,11 @@ private: public: /** - * Constructor - * build a flattened list of SCH_SHEET_PATH objects from \a aSheet. + * Build a flattened list of SCH_SHEET_PATH objects from \a aSheet. * - * If aSheet == NULL, then this is an empty hierarchy which the user can populate. + * If aSheet == NULL, then this is the full hierarchy built from the root sheet. */ - SCH_SHEET_LIST( SCH_SHEET* aSheet = NULL ); + SCH_SHEET_LIST( SCH_SHEET* aSheet = nullptr, bool aCheckIntegrity = true ); ~SCH_SHEET_LIST() {} @@ -470,15 +469,17 @@ public: SCH_SHEET* FindSheetByName( const wxString& aSheetName ); /** - * Function BuildSheetList - * builds the list of sheets and their sheet path from \a aSheet. + * Build the list of sheets and their sheet path from \a aSheet. + * * If \a aSheet is the root sheet, the full sheet path and sheet list are built. * * @param aSheet is the starting sheet from which the list is built, or NULL * indicating that g_RootSheet should be used. + * @param aIntegrityCheck set to true to test for sheet recursion while building the + * hierarchy. * @throw std::bad_alloc if the memory for the sheet path list could not be allocated. */ - void BuildSheetList( SCH_SHEET* aSheet ); + void BuildSheetList( SCH_SHEET* aSheet, bool aCheckIntegrity ); }; #endif // CLASS_DRAWSHEET_PATH_H