diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-05-27 16:55:59 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-06-10 12:42:14 +0200 |
commit | fce5dd5f6afd4864456197a5cfec20a5e8cd0e6a (patch) | |
tree | ce25f4f5fab479b60c2a20e2fa480e93c3d27836 /src | |
parent | 8a8f828e41c24afe4dc8df701f149c3d238c054a (diff) | |
download | qtlocation-mapboxgl-fce5dd5f6afd4864456197a5cfec20a5e8cd0e6a.tar.gz |
[core] TileData objects now store whether an optional load attempt was performed
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/tile/file_based_tile_source_impl.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/tile/tile_data.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/tile/tile_data.hpp | 10 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/mbgl/tile/file_based_tile_source_impl.hpp b/src/mbgl/tile/file_based_tile_source_impl.hpp index 4a11728332..b8a69e3f60 100644 --- a/src/mbgl/tile/file_based_tile_source_impl.hpp +++ b/src/mbgl/tile/file_based_tile_source_impl.hpp @@ -40,6 +40,8 @@ void FileBasedTileSource<T, I>::loadOptional() { request = fileSource.request(resource, [this](Response res) { request.reset(); + T::tileData.setTriedOptional(); + if (res.error && res.error->reason == Response::Error::Reason::NotFound) { // When the optional request could not be satisfied, don't treat it as an error. // Instead, we make sure that the next request knows that there has been an optional diff --git a/src/mbgl/tile/tile_data.cpp b/src/mbgl/tile/tile_data.cpp index a5822b2c17..a64de4d1eb 100644 --- a/src/mbgl/tile/tile_data.cpp +++ b/src/mbgl/tile/tile_data.cpp @@ -24,6 +24,11 @@ void TileData::setTileSource(std::unique_ptr<TileSource> tileSource_) { tileSource = std::move(tileSource_); } +void TileData::setTriedOptional() { + triedOptional = true; + observer->onNeedsRepaint(); +} + void TileData::dumpDebugLogs() const { Log::Info(Event::General, "TileData::id: %s", util::toString(id).c_str()); Log::Info(Event::General, "TileData::renderable: %s", isRenderable() ? "yes" : "no"); diff --git a/src/mbgl/tile/tile_data.hpp b/src/mbgl/tile/tile_data.hpp index c3877d0d63..d22e871185 100644 --- a/src/mbgl/tile/tile_data.hpp +++ b/src/mbgl/tile/tile_data.hpp @@ -50,6 +50,14 @@ public: const TransformState&, const optional<std::vector<std::string>>& layerIDs); + void setTriedOptional(); + + // Returns true when the tile source has received a first response, regardless of whether a load + // error occurred or actual data was loaded. + bool hasTriedOptional() const { + return triedOptional; + } + // Tile data considered "Renderable" can be used for rendering. Data in // partial state is still waiting for network resources but can also // be rendered, although layers will be missing. @@ -74,6 +82,8 @@ public: std::unique_ptr<DebugBucket> debugBucket; protected: + bool triedOptional = false; + enum class DataAvailability : uint8_t { // Still waiting for data to load or parse. None, |