Skip to content

Commit

Permalink
Solve JUCE_CHECK_OPENGL_ERROR false positives when closing plug-in wi…
Browse files Browse the repository at this point in the history
…ndows
  • Loading branch information
yairchu committed Aug 7, 2016
1 parent da9cc4c commit 7d371d7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions modules/juce_opengl/juce_opengl.cpp
Expand Up @@ -149,6 +149,29 @@ static void checkGLError (const char* file, const int line)
if (e == GL_NO_ERROR)
break;

// The GL error could be due to the window being closed in the main thread.
// Check whether this is the case and only if it isn't trigger an assertion failure.
OpenGLContext* currentContext = OpenGLContext::getCurrentContext();
jassert (currentContext != nullptr);
Component* component = currentContext->getTargetComponent();
if (component == nullptr)
break;
ComponentPeer* peer = component->getPeer();
if (peer == nullptr)
break;
#if JUCE_MAC
NSView* nsView = (NSView*) peer->getNativeHandle();
if (nsView == nullptr)
break;
NSWindow* nsWindow = [nsView window];
if (nsWindow == nullptr)
break;
if (! [nsWindow isVisible])
break;
if ([nsWindow hidesOnDeactivate] && ! [NSApp isActive])
break;
#endif

DBG ("***** " << getGLErrorMessage (e) << " at " << file << " : " << line);
jassertfalse;
}
Expand Down

0 comments on commit 7d371d7

Please sign in to comment.