From 415dc5482000db2fecdef45ca5d728c9c72a50b9 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Fri, 30 Nov 2018 15:49:03 +0000 Subject: [PATCH] Protected the system Random from having its seed reset --- modules/juce_core/maths/juce_Random.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/juce_core/maths/juce_Random.cpp b/modules/juce_core/maths/juce_Random.cpp index 219e1b40c8..020252a13d 100644 --- a/modules/juce_core/maths/juce_Random.cpp +++ b/modules/juce_core/maths/juce_Random.cpp @@ -38,6 +38,16 @@ Random::~Random() noexcept void Random::setSeed (const int64 newSeed) noexcept { + if (this == &getSystemRandom()) + { + // Resetting the system Random risks messing up + // JUCE's internal state. If you need a predictable + // stream of random numbers you should use a local + // Random object. + jassertfalse; + return; + } + seed = newSeed; }