Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios, macos] Fix a memory leak when creating an EAGLContext in MGLMaSnapshotter #11193

Merged
merged 1 commit into from
Feb 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions platform/darwin/src/headless_backend_eagl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
namespace mbgl {

struct EAGLImpl : public HeadlessBackend::Impl {
EAGLImpl(EAGLContext* glContext_) : glContext(glContext_) {
[reinterpret_cast<EAGLContext*>(glContext) retain];
reinterpret_cast<EAGLContext*>(glContext).multiThreaded = YES;
EAGLImpl() {
glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

if (glContext == nil) {
throw std::runtime_error("Error creating GL context object");
}
glContext.multiThreaded = YES;
}

~EAGLImpl() {
Expand Down Expand Up @@ -45,12 +49,9 @@ void deactivateContext() {
}

void HeadlessBackend::createContext() {
EAGLContext* glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (glContext == nil) {
throw std::runtime_error("Error creating GL context object");
}

impl.reset(new EAGLImpl(glContext));
impl.reset();
impl = std::make_unique<EAGLImpl>();

}

} // namespace mbgl