From a33cad98557f2d15bfb578e4795b130d25a2def2 Mon Sep 17 00:00:00 2001 From: Asheem Mamoowala Date: Wed, 14 Jun 2017 15:44:42 -0700 Subject: [PATCH] [core] Trigger repaint on source changes --- src/mbgl/style/sources/geojson_source.cpp | 1 + src/mbgl/style/sources/image_source.cpp | 4 ++-- src/mbgl/style/style.cpp | 1 + test/style/source.test.cpp | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index d04c8ffce..4e3478322 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -33,6 +33,7 @@ void GeoJSONSource::setURL(const std::string& url_) { void GeoJSONSource::setGeoJSON(const mapbox::geojson::geojson& geoJSON) { req.reset(); baseImpl = makeMutable(impl(), geoJSON); + observer->onSourceChanged(*this); } optional GeoJSONSource::getURL() const { diff --git a/src/mbgl/style/sources/image_source.cpp b/src/mbgl/style/sources/image_source.cpp index 757773d21..9313d8da4 100644 --- a/src/mbgl/style/sources/image_source.cpp +++ b/src/mbgl/style/sources/image_source.cpp @@ -20,7 +20,7 @@ const ImageSource::Impl& ImageSource::impl() const { void ImageSource::setCoordinates(const std::array& coords_) { baseImpl = makeMutable(impl(), coords_); - observer->onSourceLoaded(*this); + observer->onSourceChanged(*this); } std::array ImageSource::getCoordinates() const { @@ -44,7 +44,7 @@ void ImageSource::setImage(UnassociatedImage&& image_) { } loaded = true; baseImpl = makeMutable(impl(), std::move(image_)); - observer->onSourceLoaded(*this); + observer->onSourceChanged(*this); } optional ImageSource::getURL() const { diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 94e003df5..d667ef656 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -258,6 +258,7 @@ void Style::onSourceLoaded(Source& source) { void Style::onSourceChanged(Source& source) { sources.update(source); observer->onSourceChanged(source); + observer->onUpdate(Update::Repaint); } void Style::onSourceError(Source& source, std::exception_ptr error) { diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp index aa55db729..eaa3c7287 100644 --- a/test/style/source.test.cpp +++ b/test/style/source.test.cpp @@ -518,7 +518,7 @@ TEST(Source, ImageSourceImageUpdate) { response.data = std::make_unique(util::read_file("test/fixtures/image/no_profile.png")); return response; }; - test.styleObserver.sourceLoaded = [&] (Source&) { + test.styleObserver.sourceChanged = [&] (Source&) { // Should be called (test will hang if it doesn't) test.end(); };