diff --git a/platform/linux/src/headless_backend_egl.cpp b/platform/linux/src/headless_backend_egl.cpp index 696fa3065..cfe82d3cc 100644 --- a/platform/linux/src/headless_backend_egl.cpp +++ b/platform/linux/src/headless_backend_egl.cpp @@ -31,15 +31,15 @@ struct EGLImpl : public HeadlessBackend::Impl { } ~EGLImpl() { - if (!eglDestroyContext(display, glContext)) { - throw std::runtime_error("Failed to destroy EGL context.\n"); - } if (glSurface != EGL_NO_SURFACE) { if (!eglDestroySurface(display, glSurface)) { - throw std::runtime_error("Failed to destroy EGL context.\n"); + throw std::runtime_error("Failed to destroy EGL surface.\n"); } glSurface = EGL_NO_SURFACE; } + if (!eglDestroyContext(display, glContext)) { + throw std::runtime_error("Failed to destroy EGL context.\n"); + } } void activateContext() final {