Browse Source

Platform: explicitly destroy GL::Context before the GL context.

So in case it touches the GL state in some way, it doesn't do that on an
already destroyed context. The windowless apps do this all implicitly
due to the WindowlessGLContext encapsulation.
euler-xxx
Vladimír Vondruš 5 years ago
parent
commit
5d05acbf1f
  1. 2
      src/Magnum/Platform/AbstractXApplication.cpp
  2. 4
      src/Magnum/Platform/AndroidApplication.cpp
  3. 2
      src/Magnum/Platform/EmscriptenApplication.cpp
  4. 6
      src/Magnum/Platform/GlfwApplication.cpp
  5. 2
      src/Magnum/Platform/Sdl2Application.cpp

2
src/Magnum/Platform/AbstractXApplication.cpp

@ -109,6 +109,8 @@ bool AbstractXApplication::tryCreate(const Configuration& configuration, const G
}
AbstractXApplication::~AbstractXApplication() {
/* Destroy Magnum context first to avoid it potentially accessing the
now-destroyed GL context after */
_context.reset();
/* Shut down context handler */

4
src/Magnum/Platform/AndroidApplication.cpp

@ -77,6 +77,10 @@ AndroidApplication::AndroidApplication(const Arguments& arguments, NoCreateT): _
}
AndroidApplication::~AndroidApplication() {
/* Destroy Magnum context first to avoid it potentially accessing the
now-destroyed GL context after */
_context.reset();
eglMakeCurrent(_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(_display, _glContext);
eglDestroySurface(_display, _surface);

2
src/Magnum/Platform/EmscriptenApplication.cpp

@ -260,6 +260,8 @@ EmscriptenApplication::EmscriptenApplication(const Arguments& arguments, NoCreat
EmscriptenApplication::~EmscriptenApplication() {
#ifdef MAGNUM_TARGET_GL
/* Destroy Magnum context first to avoid it potentially accessing the
now-destroyed GL context after */
_context.reset();
emscripten_webgl_destroy_context(_glContext);

6
src/Magnum/Platform/GlfwApplication.cpp

@ -668,6 +668,12 @@ void GlfwApplication::setupCallbacks() {
}
GlfwApplication::~GlfwApplication() {
#ifdef MAGNUM_TARGET_GL
/* Destroy Magnum context first to avoid it potentially accessing the
now-destroyed GL context after */
_context.reset();
#endif
glfwDestroyWindow(_window);
for(auto& cursor: _cursors)
glfwDestroyCursor(cursor);

2
src/Magnum/Platform/Sdl2Application.cpp

@ -796,6 +796,8 @@ Sdl2Application::~Sdl2Application() {
all. */
#ifdef MAGNUM_TARGET_GL
/* Destroy Magnum context first to avoid it potentially accessing the
now-destroyed GL context after */
_context.reset();
#ifndef CORRADE_TARGET_EMSCRIPTEN

Loading…
Cancel
Save