Skip to content

Commit

Permalink
egl: make sure display is valid before cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
scribam committed Dec 12, 2023
1 parent 0433fd8 commit 6abf895
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions core/wsi/egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6abf895

Please sign in to comment.