From 6211db69680e08a1f463ec098ed843ca49a859b2 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Wed, 13 Sep 2017 14:25:03 +0300 Subject: [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 --- src/mbgl/gl/context.cpp | 4 +++- src/mbgl/gl/context.hpp | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index b8a0502178..d0c538efb0 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -87,7 +87,9 @@ static_assert(std::is_same::value, "OpenGL type mis Context::Context() = default; Context::~Context() { - reset(); + if (cleanupOnDestruction) { + reset(); + } } void Context::initializeExtensions(const std::function& 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 debugging; std::unique_ptr vertexArray; #if MBGL_HAS_BINARY_PROGRAMS -- cgit v1.2.1