From bd916b68e1a70f415b8f000a36c894bf132d5a23 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 29 Mar 2019 15:29:17 +0000 Subject: [PATCH] Make Random::setSeedRandomly() globalSeed atomic to fix a data race when multiple threads create a Random object --- modules/juce_core/maths/juce_Random.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_core/maths/juce_Random.cpp b/modules/juce_core/maths/juce_Random.cpp index 020252a13d..86b82e9f48 100644 --- a/modules/juce_core/maths/juce_Random.cpp +++ b/modules/juce_core/maths/juce_Random.cpp @@ -58,7 +58,7 @@ void Random::combineSeed (const int64 seedValue) noexcept void Random::setSeedRandomly() { - static int64 globalSeed = 0; + static std::atomic globalSeed { 0 }; combineSeed (globalSeed ^ (int64) (pointer_sized_int) this); combineSeed (Time::getMillisecondCounter());