From 063eb3b144f3581651929674ce40a3e072c09f8e Mon Sep 17 00:00:00 2001 From: "David R. MacIver" Date: Wed, 24 May 2017 10:07:07 +0100 Subject: [PATCH] Use RAII to always close display at exit. The reason for doing this is that swiftshader debug libraries will fail with an assertion error if you "leak" objects. This lets us run with the debug libraries for more comprehensible errors. --- get_image.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/get_image.cpp b/get_image.cpp index bddf172..0fa5ed3 100644 --- a/get_image.cpp +++ b/get_image.cpp @@ -327,6 +327,22 @@ int setUniforms(const GLuint& program, const std::string& fragment_shader) { return EXIT_SUCCESS; } +class TerminateEGLAtExit{ + EGLDisplay display; + + public: + TerminateEGLAtExit(EGLDisplay); + ~TerminateEGLAtExit(); +}; + +TerminateEGLAtExit::TerminateEGLAtExit(EGLDisplay display){ + this->display = display; +} + +TerminateEGLAtExit::~TerminateEGLAtExit(){ + auto succeeded = eglTerminate(this->display); + assert(succeeded); +} /*---------------------------------------------------------------------------*/ int main(int argc, char* argv[]) { @@ -349,6 +365,8 @@ int main(int argc, char* argv[]) { return EXIT_FAILURE; } + TerminateEGLAtExit cleanup_display = display; + bool persist = false; bool animate = false; bool exit_compile = false;