Browse Source

Don't assert on GL errors if the peer is not valid anymore

tags/2021-05-28
hogliux 8 years ago
parent
commit
6f94997adb
1 changed files with 54 additions and 0 deletions
  1. +54
    -0
      modules/juce_opengl/juce_opengl.cpp

+ 54
- 0
modules/juce_opengl/juce_opengl.cpp View File

@@ -142,6 +142,56 @@ static const char* getGLErrorMessage (const GLenum e) noexcept
return "Unknown error";
}
#if JUCE_MAC || JUCE_IOS
#ifndef JUCE_IOS_MAC_VIEW
#if JUCE_IOS
#define JUCE_IOS_MAC_VIEW UIView
#define JUCE_IOS_MAC_WINDOW UIWindow
#else
#define JUCE_IOS_MAC_VIEW NSView
#define JUCE_IOS_MAC_WINDOW NSWindow
#endif
#endif
#endif
static bool checkPeerIsValid (OpenGLContext* context)
{
jassert (context != nullptr);
if (context != nullptr)
{
if (auto* comp = context->getTargetComponent())
{
if (auto* peer = comp->getPeer())
{
#if JUCE_MAC || JUCE_IOS
if (auto* nsView = (JUCE_IOS_MAC_VIEW*) peer->getNativeHandle())
{
if (auto* nsWindow = [nsView window])
{
#if JUCE_MAC
return ([nsWindow isVisible]
&& (! [nsWindow hidesOnDeactivate] || [NSApp isActive]));
#else
ignoreUnused (nsWindow);
return true;
#endif
}
}
#else
return true;
#endif
}
}
}
else
jassertfalse;
return false;
}
static void checkGLError (const char* file, const int line)
{
for (;;)
@@ -151,6 +201,10 @@ static void checkGLError (const char* file, const int line)
if (e == GL_NO_ERROR)
break;
// if the peer is not valid then ignore errors
if (! checkPeerIsValid (OpenGLContext::getCurrentContext()))
continue;
DBG ("***** " << getGLErrorMessage (e) << " at " << file << " : " << line);
jassertfalse;
}


Loading…
Cancel
Save