summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-04 15:40:17 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-05 09:23:01 -0700
commitdd353a60d1656f13351e8caa69e902b7f3111a02 (patch)
tree76f94fe164b7d320ea30b575df374f2e17b652d0 /src/mbgl/style
parent54b7684baadbf6d2af559b42f10dae55d3de6354 (diff)
downloadqtlocation-mapboxgl-dd353a60d1656f13351e8caa69e902b7f3111a02.tar.gz
[core] Reset observers of removed Sources and Layers
This ensures that the observer is not an invalid reference if the removed Source/Layer is retained, but the Style is deallocated.
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/layer_impl.cpp2
-rw-r--r--src/mbgl/style/source_impl.cpp2
-rw-r--r--src/mbgl/style/style.cpp2
3 files changed, 4 insertions, 2 deletions
diff --git a/src/mbgl/style/layer_impl.cpp b/src/mbgl/style/layer_impl.cpp
index 44b1a8dd62..b8eb01fe77 100644
--- a/src/mbgl/style/layer_impl.cpp
+++ b/src/mbgl/style/layer_impl.cpp
@@ -12,7 +12,7 @@ std::unique_ptr<Layer> Layer::Impl::copy(const std::string& id_,
}
void Layer::Impl::setObserver(LayerObserver* observer_) {
- observer = observer_;
+ observer = observer_ ? observer_ : &nullObserver;
}
} // namespace style
diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp
index 8fdbd038de..1e9405abbb 100644
--- a/src/mbgl/style/source_impl.cpp
+++ b/src/mbgl/style/source_impl.cpp
@@ -20,7 +20,7 @@ void Source::Impl::dumpDebugLogs() const {
}
void Source::Impl::setObserver(SourceObserver* observer_) {
- observer = observer_;
+ observer = observer_ ? observer_ : &nullObserver;
}
} // namespace style
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index d2821751be..63fb602616 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -192,6 +192,7 @@ std::unique_ptr<Source> Style::removeSource(const std::string& id) {
});
auto source = std::move(*it);
+ source->baseImpl->setObserver(nullptr);
sources.erase(it);
updateBatch.sourceIDs.erase(id);
@@ -264,6 +265,7 @@ std::unique_ptr<Layer> Style::removeLayer(const std::string& id) {
customLayer->impl->deinitialize();
}
+ layer->baseImpl->setObserver(nullptr);
layers.erase(it);
removeRenderLayer(id);
return layer;