From d83be119472704973697b089321b14ce33cd9956 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 15 Sep 2015 17:48:07 -0700 Subject: Don't leak GlyphAtlas textures (fixes #2338) --- src/mbgl/geometry/glyph_atlas.cpp | 11 +++++++++++ src/mbgl/geometry/glyph_atlas.hpp | 1 + 2 files changed, 12 insertions(+) diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp index 43ea585531..b90444e582 100644 --- a/src/mbgl/geometry/glyph_atlas.cpp +++ b/src/mbgl/geometry/glyph_atlas.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #include @@ -20,6 +22,15 @@ GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_) dirty(true) { } +GlyphAtlas::~GlyphAtlas() { + assert(util::ThreadContext::currentlyOn(util::ThreadType::Map)); + + if (texture) { + mbgl::util::ThreadContext::getGLObjectStore()->abandonTexture(texture); + texture = 0; + } +} + void GlyphAtlas::addGlyphs(uintptr_t tileUID, const std::u32string& text, const std::string& stackName, diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp index c5c785994d..1205301835 100644 --- a/src/mbgl/geometry/glyph_atlas.hpp +++ b/src/mbgl/geometry/glyph_atlas.hpp @@ -17,6 +17,7 @@ namespace mbgl { class GlyphAtlas : public util::noncopyable { public: GlyphAtlas(uint16_t width, uint16_t height); + ~GlyphAtlas(); void addGlyphs(uintptr_t tileUID, const std::u32string& text, -- cgit v1.2.1