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
This commit is contained in:
Wayne Stambaugh 2021-10-04 15:47:16 -04:00
parent f3e9e3497b
commit 765816ccb1
9 changed files with 47 additions and 39 deletions

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -451,7 +451,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
{ {
unsigned i; unsigned i;
SCH_ITEM* item; 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 ) 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 // the destination sheet. Moreover new sheets create new sheetpaths, and component
// alternante references must be created and cleared // alternante references must be created and cleared
bool hasSheetPasted = false; bool hasSheetPasted = false;
// Keep trace of existing sheet paths. Paste block can modify this list // Keep trace of existing sheet paths. Paste block can modify this list
SCH_SHEET_LIST initial_sheetpathList( g_RootSheet ); SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ) if( !aSearchHierarchy )
sheetList.push_back( *m_CurrentSheet ); sheetList.push_back( *m_CurrentSheet );
else else
sheetList.BuildSheetList( g_RootSheet ); sheetList.BuildSheetList( g_RootSheet, false );
for( SCH_SHEET_PATHS_ITER it = sheetList.begin(); it != sheetList.end(); ++it ) for( SCH_SHEET_PATHS_ITER it = sheetList.begin(); it != sheetList.end(); ++it )
{ {

View File

@ -5,7 +5,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2010 Lorenzo Marcantonio * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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; SCH_SHEET_LIST sheetList;
if( aPlotAll ) if( aPlotAll )
sheetList.BuildSheetList( g_RootSheet ); sheetList.BuildSheetList( g_RootSheet, false );
else else
sheetList.push_back( schframe->GetCurrentSheet() ); sheetList.push_back( schframe->GetCurrentSheet() );

View File

@ -5,7 +5,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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-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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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; SCH_SHEET_LIST sheetList;
if( aPlotAll ) if( aPlotAll )
sheetList.BuildSheetList( g_RootSheet ); sheetList.BuildSheetList( g_RootSheet, false );
else else
sheetList.push_back( m_parent->GetCurrentSheet() ); sheetList.push_back( m_parent->GetCurrentSheet() );

View File

@ -5,7 +5,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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-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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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; SCH_SHEET_LIST sheetList;
if( aPlotAll ) if( aPlotAll )
sheetList.BuildSheetList( g_RootSheet ); sheetList.BuildSheetList( g_RootSheet, false );
else else
sheetList.push_back( m_parent->GetCurrentSheet() ); sheetList.push_back( m_parent->GetCurrentSheet() );

View File

@ -4,7 +4,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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; SCH_SHEET_LIST sheetList;
if( aPlotAll ) if( aPlotAll )
sheetList.BuildSheetList( g_RootSheet ); sheetList.BuildSheetList( g_RootSheet, false );
else else
sheetList.push_back( m_parent->GetCurrentSheet() ); sheetList.push_back( m_parent->GetCurrentSheet() );

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2016 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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; SCH_SHEET_LIST sheetList;
if( aPrintAll ) if( aPrintAll )
sheetList.BuildSheetList( g_RootSheet ); sheetList.BuildSheetList( g_RootSheet, false );
else else
sheetList.push_back( m_parent->GetCurrentSheet() ); sheetList.push_back( m_parent->GetCurrentSheet() );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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, void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
bool aForceIncludeOrphanComponents ) bool aForceIncludeOrphanComponents )
{ {
@ -423,15 +422,12 @@ SCH_SHEET* SCH_SHEET_PATH::FindSheetByName( const wxString& aSheetName )
} }
/********************************************************************/ SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet, bool aCheckIntegrity )
/* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */
/********************************************************************/
SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet )
{ {
m_isRootSheet = false; m_isRootSheet = false;
if( aSheet != NULL ) 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." ) ); 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; SCH_SHEET* sheet = (SCH_SHEET*) item;
if( !m_currentSheetPath.TestForRecursion( if( aCheckIntegrity )
sheet->GetFileName(), aSheet->GetFileName() ) ) {
BuildSheetList( sheet ); if( !m_currentSheetPath.TestForRecursion( sheet->GetFileName(),
aSheet->GetFileName() ) )
BuildSheetList( sheet, true );
else
badSheets.push_back( sheet );
}
else else
badSheets.push_back( sheet ); {
BuildSheetList( sheet, false );
}
} }
item = item->Next(); item = item->Next();
} }
if( aCheckIntegrity )
for( auto sheet : badSheets )
{ {
aSheet->GetScreen()->Remove( sheet ); for( auto sheet : badSheets )
aSheet->GetScreen()->SetModify(); {
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 ); (*it).GetComponents( aReferences, aIncludePowerSymbols, aForceIncludeOrphanComponents );
} }
void SCH_SHEET_LIST::GetMultiUnitComponents( SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, void SCH_SHEET_LIST::GetMultiUnitComponents( SCH_MULTI_UNIT_REFERENCE_MAP &aRefList,
bool aIncludePowerSymbols ) bool aIncludePowerSymbols )
{ {

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -330,12 +330,11 @@ private:
public: 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() {} ~SCH_SHEET_LIST() {}
@ -470,15 +469,17 @@ public:
SCH_SHEET* FindSheetByName( const wxString& aSheetName ); SCH_SHEET* FindSheetByName( const wxString& aSheetName );
/** /**
* Function BuildSheetList * Build the list of sheets and their sheet path from \a aSheet.
* builds 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. * 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 * @param aSheet is the starting sheet from which the list is built, or NULL
* indicating that g_RootSheet should be used. * 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. * @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 #endif // CLASS_DRAWSHEET_PATH_H