From 0da6d8a646746831819525fd37cff3ed0af9589b Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Mon, 6 Mar 2017 17:19:38 -0800 Subject: [PATCH] [core] clear source when removed from style --- src/mbgl/style/source_impl.cpp | 4 ++++ src/mbgl/style/source_impl.hpp | 3 +++ src/mbgl/style/style.cpp | 1 + 3 files changed, 8 insertions(+) diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp index 22e51f88852..fdacb00b4c0 100644 --- a/src/mbgl/style/source_impl.cpp +++ b/src/mbgl/style/source_impl.cpp @@ -44,6 +44,10 @@ bool Source::Impl::isLoaded() const { return true; } + +void Source::Impl::detach() { + invalidateTiles(); +} void Source::Impl::invalidateTiles() { tiles.clear(); diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp index ea2135c3c1c..54af93c04f7 100644 --- a/src/mbgl/style/source_impl.hpp +++ b/src/mbgl/style/source_impl.hpp @@ -87,6 +87,9 @@ class Source::Impl : public TileObserver, private util::noncopyable { // be initialized to true so that Style::isLoaded() does not produce false positives if // called before Style::recalculate(). bool enabled = true; + + // Detaches from the style + void detach(); protected: void invalidateTiles(); diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index aacf811f4d9..5b45ca27ef4 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -166,6 +166,7 @@ std::unique_ptr Style::removeSource(const std::string& id) { sources.erase(it); updateBatch.sourceIDs.erase(id); + source->baseImpl->detach(); return source; }