[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
This commit is contained in:
Ivo van Dongen
2017-09-13 14:25:03 +03:00
committed by Ivo van Dongen
parent e0312ef208
commit 6211db6968
2 changed files with 9 additions and 1 deletions

View File

@@ -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) {

View File

@@ -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