diff options
author | Ander Conselvan de Oliveira <ander.deoliveira@mapbox.com> | 2019-11-04 08:12:23 +0200 |
---|---|---|
committer | Ander Conselvan de Oliveira <ander.deoliveira@mapbox.com> | 2019-11-05 04:43:31 +0200 |
commit | 2dbb7f5064c56a3c15741c8fd023d07c2c0ad209 (patch) | |
tree | 0ad50e13c055be777a7978f9d41e3928d0fa91d8 /platform | |
parent | d8b1b2bacf0dd9812d62077a825067441037791b (diff) | |
download | qtlocation-mapboxgl-upstream/anderco-win-snapshot.tar.gz |
Fix MapSnapshotter build failure on Windowsupstream/anderco-win-snapshot
MSVC implementation of std::promise is buggy and only works with types
that can be default-constructed. Wrap LatLngBounds in such a struct to
avoid a compilation failure in the instantiation of ask() inside
MapSnapshotter::getRegion() since that would create a
std::promise<LanLngBounds>.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/src/mbgl/map/map_snapshotter.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/platform/default/src/mbgl/map/map_snapshotter.cpp b/platform/default/src/mbgl/map/map_snapshotter.cpp index 705a791af9..0c94eadc33 100644 --- a/platform/default/src/mbgl/map/map_snapshotter.cpp +++ b/platform/default/src/mbgl/map/map_snapshotter.cpp @@ -12,6 +12,17 @@ namespace mbgl { +/* + * MSVC implementation of std::promise is buggy and only works with types that can be default-constructed. + * Wrap LatLngBounds in such a struct to avoid a compilation failure in the instantiation of ask() inside + * MapSnapshotter::getRegion() since that would create a std::promise<LanLngBounds>. + */ +struct RegionWrapper { + explicit RegionWrapper() : region(LatLngBounds::unbounded()) {} + + LatLngBounds region; +}; + class MapSnapshotter::Impl { public: Impl(const std::pair<bool, std::string> style, @@ -35,7 +46,7 @@ public: CameraOptions getCameraOptions() const; void setRegion(LatLngBounds); - LatLngBounds getRegion() const; + RegionWrapper getRegion() const; void snapshot(ActorRef<MapSnapshotter::Callback>); @@ -157,8 +168,10 @@ void MapSnapshotter::Impl::setRegion(LatLngBounds region) { map.jumpTo(map.cameraForLatLngs(latLngs, insets)); } -LatLngBounds MapSnapshotter::Impl::getRegion() const { - return map.latLngBoundsForCamera(getCameraOptions()); +RegionWrapper MapSnapshotter::Impl::getRegion() const { + RegionWrapper region; + region.region = map.latLngBoundsForCamera(getCameraOptions()); + return region; } MapSnapshotter::MapSnapshotter(const std::pair<bool, std::string> style, @@ -215,7 +228,7 @@ void MapSnapshotter::setRegion(const LatLngBounds& bounds) { } LatLngBounds MapSnapshotter::getRegion() const { - return impl->actor().ask(&Impl::getRegion).get(); + return impl->actor().ask(&Impl::getRegion).get().region; } } // namespace mbgl |