[core] s/onSourceDidChange/onSourceChanged/ + source ref
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/style/source.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -33,7 +36,7 @@ public:
|
||||
virtual void onWillStartRenderingMap() {}
|
||||
virtual void onDidFinishRenderingMap(RenderMode) {}
|
||||
virtual void onDidFinishLoadingStyle() {}
|
||||
virtual void onSourceDidChange() {}
|
||||
virtual void onSourceChanged(style::Source&) {}
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
ConstrainMode,
|
||||
ViewportMode);
|
||||
|
||||
void onSourceAttributionChanged(style::Source&, const std::string&) override;
|
||||
void onSourceChanged(style::Source&) override;
|
||||
void onUpdate(Update) override;
|
||||
void onStyleLoaded() override;
|
||||
void onStyleError(std::exception_ptr) override;
|
||||
@@ -1089,8 +1089,8 @@ void Map::onLowMemory() {
|
||||
}
|
||||
}
|
||||
|
||||
void Map::Impl::onSourceAttributionChanged(style::Source&, const std::string&) {
|
||||
observer.onSourceDidChange();
|
||||
void Map::Impl::onSourceChanged(style::Source& source) {
|
||||
observer.onSourceChanged(source);
|
||||
}
|
||||
|
||||
void Map::Impl::onUpdate(Update flags) {
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
virtual ~SourceObserver() = default;
|
||||
|
||||
virtual void onSourceLoaded(Source&) {}
|
||||
virtual void onSourceAttributionChanged(Source&, const std::string&) {}
|
||||
virtual void onSourceChanged(Source&) {}
|
||||
virtual void onSourceError(Source&, std::exception_ptr) {}
|
||||
|
||||
// Source description needs to be reloaded
|
||||
|
||||
@@ -593,8 +593,8 @@ void Style::onSourceLoaded(Source& source) {
|
||||
observer->onUpdate(Update::Repaint);
|
||||
}
|
||||
|
||||
void Style::onSourceAttributionChanged(Source& source, const std::string& attribution) {
|
||||
observer->onSourceAttributionChanged(source, attribution);
|
||||
void Style::onSourceChanged(Source& source) {
|
||||
observer->onSourceChanged(source);
|
||||
}
|
||||
|
||||
void Style::onSourceError(Source& source, std::exception_ptr error) {
|
||||
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
|
||||
// SourceObserver implementation.
|
||||
void onSourceLoaded(Source&) override;
|
||||
void onSourceAttributionChanged(Source&, const std::string&) override;
|
||||
void onSourceChanged(Source&) override;
|
||||
void onSourceError(Source&, std::exception_ptr) override;
|
||||
void onSourceDescriptionChanged(Source&) override;
|
||||
void onTileChanged(Source&, const OverscaledTileID&) override;
|
||||
|
||||
@@ -107,7 +107,7 @@ void TileSourceImpl::loadDescription(FileSource& fileSource) {
|
||||
|
||||
observer->onSourceLoaded(base);
|
||||
if (attributionChanged) {
|
||||
observer->onSourceAttributionChanged(base, newTileset.attribution);
|
||||
observer->onSourceChanged(base);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,8 +30,8 @@ public:
|
||||
if (sourceLoaded) sourceLoaded(source);
|
||||
}
|
||||
|
||||
void onSourceAttributionChanged(Source& source, const std::string& attribution) override {
|
||||
if (sourceAttributionChanged) sourceAttributionChanged(source, attribution);
|
||||
void onSourceChanged(Source& source) override {
|
||||
if (sourceChanged) sourceChanged(source);
|
||||
}
|
||||
|
||||
void onSourceError(Source& source, std::exception_ptr error) override {
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
std::function<void ()> spriteLoaded;
|
||||
std::function<void (std::exception_ptr)> spriteError;
|
||||
std::function<void (Source&)> sourceLoaded;
|
||||
std::function<void (Source&, std::string)> sourceAttributionChanged;
|
||||
std::function<void (Source&)> sourceChanged;
|
||||
std::function<void (Source&, std::exception_ptr)> sourceError;
|
||||
std::function<void (Source&)> sourceDescriptionChanged;
|
||||
std::function<void (Source&, const OverscaledTileID&)> tileChanged;
|
||||
|
||||
@@ -388,8 +388,8 @@ TEST(Source, RasterTileAttribution) {
|
||||
return response;
|
||||
};
|
||||
|
||||
test.observer.sourceAttributionChanged = [&] (Source&, std::string attribution) {
|
||||
EXPECT_EQ(mapboxOSM, attribution);
|
||||
test.observer.sourceChanged = [&] (Source& source) {
|
||||
EXPECT_EQ(mapboxOSM, source.getAttribution());
|
||||
EXPECT_FALSE(mapboxOSM.find("©️ OpenStreetMap") == std::string::npos);
|
||||
test.end();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user