egl: make sure display is valid before cleanup

This commit is contained in:
scribam 2023-12-12 22:43:18 +01:00 committed by flyinghead
parent bf4346c849
commit 00954f1b60
1 changed files with 11 additions and 5 deletions

View File

@ -164,13 +164,19 @@ bool EGLGraphicsContext::init()
void EGLGraphicsContext::term()
{
preTerm();
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (context != EGL_NO_CONTEXT)
eglDestroyContext(display, context);
if (surface != EGL_NO_SURFACE)
eglDestroySurface(display, surface);
if (display != EGL_NO_DISPLAY)
{
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (context != EGL_NO_CONTEXT)
eglDestroyContext(display, context);
if (surface != EGL_NO_SURFACE)
eglDestroySurface(display, surface);
eglTerminate(display);
}
context = EGL_NO_CONTEXT;
surface = EGL_NO_SURFACE;