From bbc0c61ccbefd8555333a5f33d3ffc3b52210ecf Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sun, 7 Aug 2022 02:22:11 -0500 Subject: [PATCH] kiid.cpp: Fix Boost version incompatibility and use of boost::*::detail Fix compile with Boost 1.65.1 (and possibly some or all of the 1.59-1.66 range); remove dependence on private boost::*::detail members. Fixes https://gitlab.com/kicad/code/kicad/-/issues/12175 Comment tweaks by Mark Roszko @mroszko --- common/kiid.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/common/kiid.cpp b/common/kiid.cpp index faad537e60..a00added34 100644 --- a/common/kiid.cpp +++ b/common/kiid.cpp @@ -41,14 +41,11 @@ static std::mutex rng_mutex; // Static rng and generators are used because the overhead of constant seeding is expensive -// We break out the rng separately from the generator because we want to control seeding in cases like unit tests -#if BOOST_VERSION >= 106700 -static boost::uuids::detail::random_provider seeder; // required to ensure the rng has a random initial seed -#else -static boost::uuids::detail::seed_rng seeder; // required to ensure the rng has a random initial seed -#endif -static boost::mt19937 rng( seeder ); -static boost::uuids::basic_random_generator randomGenerator( rng ); +// We rely on the default non-arg constructor of basic_random_generator to provide a random seed. +// We use a separate rng object for cases where we want to control the basic_random_generator +// initial seed by calling SeedGenerator from unit tests and other special cases. +static boost::mt19937 rng; +static boost::uuids::basic_random_generator randomGenerator; // These don't have the same performance penalty, but we might as well be consistent static boost::uuids::string_generator stringGenerator; @@ -279,6 +276,7 @@ void KIID::CreateNilUuids( bool aNil ) void KIID::SeedGenerator( unsigned int aSeed ) { rng.seed( aSeed ); + randomGenerator = boost::uuids::basic_random_generator( rng ); }