[core] Trigger repaint on source changes

This commit is contained in:
Asheem Mamoowala
2017-06-14 15:44:42 -07:00
parent ca45974ff2
commit a33cad9855
4 changed files with 5 additions and 3 deletions

View File

@@ -33,6 +33,7 @@ void GeoJSONSource::setURL(const std::string& url_) {
void GeoJSONSource::setGeoJSON(const mapbox::geojson::geojson& geoJSON) {
req.reset();
baseImpl = makeMutable<Impl>(impl(), geoJSON);
observer->onSourceChanged(*this);
}
optional<std::string> GeoJSONSource::getURL() const {

View File

@@ -20,7 +20,7 @@ const ImageSource::Impl& ImageSource::impl() const {
void ImageSource::setCoordinates(const std::array<LatLng, 4>& coords_) {
baseImpl = makeMutable<Impl>(impl(), coords_);
observer->onSourceLoaded(*this);
observer->onSourceChanged(*this);
}
std::array<LatLng, 4> ImageSource::getCoordinates() const {
@@ -44,7 +44,7 @@ void ImageSource::setImage(UnassociatedImage&& image_) {
}
loaded = true;
baseImpl = makeMutable<Impl>(impl(), std::move(image_));
observer->onSourceLoaded(*this);
observer->onSourceChanged(*this);
}
optional<std::string> ImageSource::getURL() const {

View File

@@ -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) {

View File

@@ -518,7 +518,7 @@ TEST(Source, ImageSourceImageUpdate) {
response.data = std::make_unique<std::string>(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();
};