diff --git a/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp b/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp index 3ea38480ea..af7ebc2c54 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp @@ -98,12 +98,8 @@ ProjectTreeViewBase* ProjectTreeViewBase::findTreeViewItem (const Project::Item& for (int i = getNumSubItems(); --i >= 0;) { if (ProjectTreeViewBase* pg = dynamic_cast (getSubItem(i))) - { - pg = pg->findTreeViewItem (itemToFind); - - if (pg != nullptr) - return pg; - } + if (ProjectTreeViewBase* found = pg->findTreeViewItem (itemToFind)) + return found; } setOpen (wasOpen); @@ -122,15 +118,9 @@ void ProjectTreeViewBase::triggerAsyncRename (const Project::Item& itemToRename) void messageCallback() { if (tree != nullptr) - { - if (ProjectTreeViewBase* pg = dynamic_cast (tree->getRootItem())) - { - pg = pg->findTreeViewItem (itemToRename); - - if (pg != nullptr) - pg->showRenameBox(); - } - } + if (ProjectTreeViewBase* root = dynamic_cast (tree->getRootItem())) + if (ProjectTreeViewBase* found = root->findTreeViewItem (itemToRename)) + found->showRenameBox(); } private: diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 720bfdf7ba..a898a6885d 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -37,7 +37,7 @@ public: #else shadersAvailable (false), #endif - needsUpdate (true) + needsUpdate (1) { nativeContext = new NativeContext (component, pixFormat, contextToShare); @@ -90,7 +90,7 @@ public: void triggerRepaint() { - needsUpdate = true; + needsUpdate = 1; #if JUCE_ANDROID if (nativeContext != nullptr) @@ -143,7 +143,9 @@ public: { ScopedPointer mmLock; - if (context.renderComponents && needsUpdate) + const bool isUpdating = needsUpdate.compareAndSetBool (0, 1); + + if (context.renderComponents && isUpdating) { mmLock = new MessageManagerLock (this); // need to acquire this before locking the context. if (! mmLock->lockWasGained()) @@ -166,9 +168,8 @@ public: if (context.renderComponents) { - if (needsUpdate) + if (isUpdating) { - needsUpdate = false; paintComponent(); mmLock = nullptr; } @@ -357,8 +358,8 @@ public: ReferenceCountedArray associatedObjects; WaitableEvent canPaintNowFlag, finishedPaintingFlag; - bool volatile shadersAvailable; - bool volatile needsUpdate; + bool shadersAvailable; + Atomic needsUpdate; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CachedImage) };