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.
This commit is contained in:
jpark37 2019-07-15 09:13:14 -07:00
parent 8af49016fa
commit b90ce6944f

View File

@ -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;
}