1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed a potential data race in OpenGLContext::CachedImage

This commit is contained in:
ed 2020-01-14 17:51:39 +00:00
parent 379e8410fb
commit b2d8f45e14

View file

@ -105,7 +105,7 @@ public:
if (renderThread != nullptr)
{
// make sure everything has finished executing
destroying.set (1);
destroying = true;
if (workQueue.size() > 0)
{
@ -224,7 +224,9 @@ public:
bool renderFrame()
{
MessageManager::Lock::ScopedTryLockType mmLock (messageManagerLock, false);
const bool isUpdating = needsUpdate.compareAndSetBool (0, 1);
auto isUpdatingTestValue = true;
auto isUpdating = needsUpdate.compare_exchange_strong (isUpdatingTestValue, false);
if (context.renderComponents && isUpdating)
{
@ -613,7 +615,7 @@ public:
void execute (OpenGLContext::AsyncWorker::Ptr workerToUse, bool shouldBlock, bool calledFromDestructor = false)
{
if (calledFromDestructor || destroying.get() == 0)
if (calledFromDestructor || ! destroying)
{
if (shouldBlock)
{
@ -671,8 +673,7 @@ public:
#else
bool shadersAvailable = false;
#endif
bool hasInitialised = false;
Atomic<int> needsUpdate { 1 }, destroying;
std::atomic<bool> hasInitialised { false }, needsUpdate { true }, destroying { false };
uint32 lastMMLockReleaseTime = 0;
#if JUCE_MAC