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

Commit

Permalink
[ios, macos] Fix a memory leak when creating an EAGLContext in MGLMap…
Browse files Browse the repository at this point in the history
…Snapshotter. (#11193)
  • Loading branch information
fabian-guerra authored Feb 27, 2018
1 parent aacd55c commit 6d2cbb0
Showing 1 changed file with 10 additions and 9 deletions.
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

0 comments on commit 6d2cbb0

Please sign in to comment.