Browse Source

Fixed some dodgy threading in the openGL rendering context.

tags/2021-05-28
jules 13 years ago
parent
commit
ff20ad64f3
2 changed files with 13 additions and 22 deletions
  1. +5
    -15
      extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp
  2. +8
    -7
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp

+ 5
- 15
extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp View File

@@ -98,12 +98,8 @@ ProjectTreeViewBase* ProjectTreeViewBase::findTreeViewItem (const Project::Item&
for (int i = getNumSubItems(); --i >= 0;) for (int i = getNumSubItems(); --i >= 0;)
{ {
if (ProjectTreeViewBase* pg = dynamic_cast <ProjectTreeViewBase*> (getSubItem(i))) if (ProjectTreeViewBase* pg = dynamic_cast <ProjectTreeViewBase*> (getSubItem(i)))
{
pg = pg->findTreeViewItem (itemToFind);
if (pg != nullptr)
return pg;
}
if (ProjectTreeViewBase* found = pg->findTreeViewItem (itemToFind))
return found;
} }
setOpen (wasOpen); setOpen (wasOpen);
@@ -122,15 +118,9 @@ void ProjectTreeViewBase::triggerAsyncRename (const Project::Item& itemToRename)
void messageCallback() void messageCallback()
{ {
if (tree != nullptr) if (tree != nullptr)
{
if (ProjectTreeViewBase* pg = dynamic_cast <ProjectTreeViewBase*> (tree->getRootItem()))
{
pg = pg->findTreeViewItem (itemToRename);
if (pg != nullptr)
pg->showRenameBox();
}
}
if (ProjectTreeViewBase* root = dynamic_cast <ProjectTreeViewBase*> (tree->getRootItem()))
if (ProjectTreeViewBase* found = root->findTreeViewItem (itemToRename))
found->showRenameBox();
} }
private: private:


+ 8
- 7
modules/juce_opengl/opengl/juce_OpenGLContext.cpp View File

@@ -37,7 +37,7 @@ public:
#else #else
shadersAvailable (false), shadersAvailable (false),
#endif #endif
needsUpdate (true)
needsUpdate (1)
{ {
nativeContext = new NativeContext (component, pixFormat, contextToShare); nativeContext = new NativeContext (component, pixFormat, contextToShare);
@@ -90,7 +90,7 @@ public:
void triggerRepaint() void triggerRepaint()
{ {
needsUpdate = true;
needsUpdate = 1;
#if JUCE_ANDROID #if JUCE_ANDROID
if (nativeContext != nullptr) if (nativeContext != nullptr)
@@ -143,7 +143,9 @@ public:
{ {
ScopedPointer<MessageManagerLock> mmLock; ScopedPointer<MessageManagerLock> 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. mmLock = new MessageManagerLock (this); // need to acquire this before locking the context.
if (! mmLock->lockWasGained()) if (! mmLock->lockWasGained())
@@ -166,9 +168,8 @@ public:
if (context.renderComponents) if (context.renderComponents)
{ {
if (needsUpdate)
if (isUpdating)
{ {
needsUpdate = false;
paintComponent(); paintComponent();
mmLock = nullptr; mmLock = nullptr;
} }
@@ -357,8 +358,8 @@ public:
ReferenceCountedArray<ReferenceCountedObject> associatedObjects; ReferenceCountedArray<ReferenceCountedObject> associatedObjects;
WaitableEvent canPaintNowFlag, finishedPaintingFlag; WaitableEvent canPaintNowFlag, finishedPaintingFlag;
bool volatile shadersAvailable;
bool volatile needsUpdate;
bool shadersAvailable;
Atomic<int> needsUpdate;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CachedImage) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CachedImage)
}; };


Loading…
Cancel
Save