diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-09-13 14:25:03 +0300 |
---|---|---|
committer | Ivo van Dongen <info@ivovandongen.nl> | 2017-09-13 14:37:11 +0300 |
commit | e76d7df35a26c8e6274d5386463145506a3cf160 (patch) | |
tree | 8beeb51fefd3d077b56dcbfa338ed50f2a7e598b | |
parent | b186d61d927083be83882b1d1a33eedc64c58d90 (diff) | |
download | qtlocation-mapboxgl-e76d7df35a26c8e6274d5386463145506a3cf160.tar.gz |
[core] allow context to be abandoned on destruction
- This enables the use case where the system already destroyed the underlying GL resources. Otherwise, the cleanup would fail and crash
-rw-r--r-- | src/mbgl/gl/context.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 49bfe30e91..a7af656a24 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -87,7 +87,9 @@ static_assert(std::is_same<BinaryProgramFormat, GLenum>::value, "OpenGL type mis Context::Context() = default; Context::~Context() { - reset(); + if (cleanupOnDestruction) { + reset(); + } } void Context::initializeExtensions(const std::function<gl::ProcAddress(const char*)>& getProcAddress) { diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 228e6e55b7..528113cbba 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -190,7 +190,13 @@ public: return vertexArray.get(); } + void setCleanupOnDestruction(bool cleanup) { + cleanupOnDestruction = cleanup; + } + private: + bool cleanupOnDestruction = true; + std::unique_ptr<extension::Debugging> debugging; std::unique_ptr<extension::VertexArray> vertexArray; #if MBGL_HAS_BINARY_PROGRAMS |