Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit eba51de

Browse files
author
Asheem Mamoowala
committed
[core] Trigger repaint on source changes
1 parent 19d3d16 commit eba51de

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/mbgl/style/sources/geojson_source.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void GeoJSONSource::setURL(const std::string& url_) {
3333
void GeoJSONSource::setGeoJSON(const mapbox::geojson::geojson& geoJSON) {
3434
req.reset();
3535
baseImpl = makeMutable<Impl>(impl(), geoJSON);
36+
observer->onSourceChanged(*this);
3637
}
3738

3839
optional<std::string> GeoJSONSource::getURL() const {

src/mbgl/style/sources/image_source.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ImageSource::Impl& ImageSource::impl() const {
2020

2121
void ImageSource::setCoordinates(const std::array<LatLng, 4>& coords_) {
2222
baseImpl = makeMutable<Impl>(impl(), coords_);
23-
observer->onSourceLoaded(*this);
23+
observer->onSourceChanged(*this);
2424
}
2525

2626
std::array<LatLng, 4> ImageSource::getCoordinates() const {
@@ -44,7 +44,7 @@ void ImageSource::setImage(UnassociatedImage&& image_) {
4444
}
4545
loaded = true;
4646
baseImpl = makeMutable<Impl>(impl(), std::move(image_));
47-
observer->onSourceLoaded(*this);
47+
observer->onSourceChanged(*this);
4848
}
4949

5050
optional<std::string> ImageSource::getURL() const {

src/mbgl/style/style.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ void Style::onSourceLoaded(Source& source) {
257257
void Style::onSourceChanged(Source& source) {
258258
sources.update(source);
259259
observer->onSourceChanged(source);
260+
observer->onUpdate(Update::Repaint);
260261
}
261262

262263
void Style::onSourceError(Source& source, std::exception_ptr error) {

test/style/source.test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ TEST(Source, ImageSourceImageUpdate) {
518518
response.data = std::make_unique<std::string>(util::read_file("test/fixtures/image/no_profile.png"));
519519
return response;
520520
};
521-
test.styleObserver.sourceLoaded = [&] (Source&) {
521+
test.styleObserver.sourceChanged = [&] (Source&) {
522522
// Should be called (test will hang if it doesn't)
523523
test.end();
524524
};

0 commit comments

Comments
 (0)