From b90ce6944fa4d575e92e35696785342bf1051d22 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Mon, 15 Jul 2019 09:13:14 -0700 Subject: [PATCH] libobs-opengl: Fix glGetError() infinite loop glGetError() returns GL_INVALID_OPERATION during OBS shutdown when GL is used on Windows. This change gives up after eight errors. This could be avoided by stopping the graphics thread before window destruction, but the shutdown code looks like it could be tricky to reorder. --- libobs-opengl/gl-helpers.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libobs-opengl/gl-helpers.h b/libobs-opengl/gl-helpers.h index 779d070d5..c2ed44456 100644 --- a/libobs-opengl/gl-helpers.h +++ b/libobs-opengl/gl-helpers.h @@ -27,10 +27,18 @@ static inline bool gl_success(const char *funcname) { GLenum errorcode = glGetError(); if (errorcode != GL_NO_ERROR) { + int attempts = 8; do { blog(LOG_ERROR, "%s failed, glGetError returned 0x%X", funcname, errorcode); errorcode = glGetError(); + + --attempts; + if (attempts == 0) { + blog(LOG_ERROR, "Too many GL errors, moving on", + funcname, errorcode); + break; + } } while (errorcode != GL_NO_ERROR); return false; }