From cb77babe52681d56d5bbc1f953cba9d9d1e5b337 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 22 Feb 2018 01:21:46 +0000 Subject: [PATCH] Only load all the libraries for a keyword or wildcard search. --- pcbnew/load_select_footprint.cpp | 60 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index d68dff5d80..8212e66268 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -199,40 +199,42 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, return NULL; } - // While some of the search methods can load a libraray at a time (and stop when - // a match is found), the async loader gives much better feedback and loads the - // libraries in parallel. - // If the footprints are already in the cache, ReadFootprintFiles() will return - // immediately. - WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 ); - MList.ReadFootprintFiles( aTable, libName.length() ? &libName : nullptr, &progressReporter ); - progressReporter.Show( false ); - - if( MList.GetErrorCount() ) - MList.DisplayErrors( this ); - - if( dlg.IsKeyword() ) // Selection by keywords + if( dlg.IsKeyword() || moduleName.Contains( wxT( "?" ) ) || moduleName.Contains( wxT( "*" ) ) ) { - allowWildSeach = false; - keys = moduleName; - moduleName = SelectFootprint( this, libName, wxEmptyString, keys, aTable ); + // While SelectFootprint() can load a library at a time (and stop when a match + // is found), the async loader gives much better feedback and loads the libraries + // in parallel. + // If the footprints are already in the cache, ReadFootprintFiles() will return + // immediately. + WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 ); + MList.ReadFootprintFiles( aTable, libName.length() ? &libName : NULL, &progressReporter ); + progressReporter.Show( false ); - if( moduleName.IsEmpty() ) // Cancel command + if( MList.GetErrorCount() ) + MList.DisplayErrors( this ); + + if( dlg.IsKeyword() ) // Selection by keywords { - m_canvas->MoveCursorToCrossHair(); - return NULL; + allowWildSeach = false; + keys = moduleName; + moduleName = SelectFootprint( this, libName, wxEmptyString, keys, aTable ); + + if( moduleName.IsEmpty() ) // Cancel command + { + m_canvas->MoveCursorToCrossHair(); + return NULL; + } } - } - else if( moduleName.Contains( wxT( "?" ) ) - || moduleName.Contains( wxT( "*" ) ) ) // Selection wild card - { - allowWildSeach = false; - moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable ); - - if( moduleName.IsEmpty() ) + else // Selection wild card { - m_canvas->MoveCursorToCrossHair(); - return NULL; // Cancel command. + allowWildSeach = false; + moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable ); + + if( moduleName.IsEmpty() ) + { + m_canvas->MoveCursorToCrossHair(); + return NULL; // Cancel command. + } } }