From eba51de3b330596abe07955e77f6369a569d028d 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 d04c8ffce47..4e3478322de 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 757773d218b..9313d8da4ab 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 27ca58e85da..26601f25d7e 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -257,6 +257,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 aa55db72929..eaa3c728774 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(); };