Don't generate real random UUIDs while loading libraries

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7921
This commit is contained in:
Jon Evans 2021-03-14 17:50:49 -04:00
parent 7f8ea6e06a
commit 6d502cb2a5
4 changed files with 25 additions and 1 deletions

View File

@ -174,6 +174,9 @@ void FOOTPRINT_ASYNC_LOADER::SetList( FOOTPRINT_LIST* aList )
void FOOTPRINT_ASYNC_LOADER::Start( FP_LIB_TABLE* aTable, wxString const* aNickname, void FOOTPRINT_ASYNC_LOADER::Start( FP_LIB_TABLE* aTable, wxString const* aNickname,
unsigned aNThreads ) unsigned aNThreads )
{ {
// Disable KIID generation: not needed for library parts; sometimes very slow
KIID::CreateNilUuids( true );
// Capture the FP_LIB_TABLE into m_last_table. Formatting it as a string instead of storing the // Capture the FP_LIB_TABLE into m_last_table. Formatting it as a string instead of storing the
// raw data avoids having to pull in the FP-specific parts. // raw data avoids having to pull in the FP-specific parts.
STRING_FORMATTER sof; STRING_FORMATTER sof;
@ -204,4 +207,6 @@ void FOOTPRINT_ASYNC_LOADER::Abort()
m_list->stopWorkers(); m_list->stopWorkers();
m_list = nullptr; m_list = nullptr;
} }
KIID::CreateNilUuids( false );
} }

View File

@ -47,6 +47,9 @@ static boost::uuids::nil_generator nilGenerator;
// Global nil reference // Global nil reference
KIID niluuid( 0 ); KIID niluuid( 0 );
// When true, always create nil uuids for performance, when valid ones aren't needed
static bool createNilUuids = false;
// For static initialization // For static initialization
KIID& NilUuid() KIID& NilUuid()
@ -65,7 +68,10 @@ KIID::KIID()
{ {
#endif #endif
m_uuid = randomGenerator(); if( createNilUuids )
m_uuid = nilGenerator();
else
m_uuid = randomGenerator();
#if BOOST_VERSION >= 106700 #if BOOST_VERSION >= 106700
} }
@ -232,6 +238,12 @@ void KIID::ConvertTimestampToUuid()
} }
void KIID::CreateNilUuids( bool aNil )
{
createNilUuids = aNil;
}
KIID_PATH::KIID_PATH( const wxString& aString ) KIID_PATH::KIID_PATH( const wxString& aString )
{ {
for( const wxString& pathStep : wxSplit( aString, '/' ) ) for( const wxString& pathStep : wxSplit( aString, '/' ) )

View File

@ -65,6 +65,9 @@ void SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
aNicknames.size(), aParent ); aNicknames.size(), aParent );
} }
// Disable KIID generation: not needed for library parts; sometimes very slow
KIID::CreateNilUuids( true );
unsigned int ii = 0; unsigned int ii = 0;
for( const auto& nickname : aNicknames ) for( const auto& nickname : aNicknames )
@ -80,6 +83,8 @@ void SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
ii++; ii++;
} }
KIID::CreateNilUuids( false );
m_tree.AssignIntrinsicRanks(); m_tree.AssignIntrinsicRanks();
if( prg ) if( prg )

View File

@ -61,6 +61,8 @@ public:
static bool SniffTest( const wxString& aCandidate ); static bool SniffTest( const wxString& aCandidate );
static void CreateNilUuids( bool aNil = true );
/** /**
* Change an existing time stamp based UUID into a true UUID. * Change an existing time stamp based UUID into a true UUID.
* *