From 86c726373469936270a1fe7a5ac9ca15f91546c1 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 28 Nov 2019 18:42:11 +0200 Subject: [PATCH] [core] Fix supercluster lambdas capturing --- src/mbgl/style/sources/geojson_source_impl.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index f716b81c5b8..962d6bd060e 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -91,24 +91,24 @@ std::shared_ptr GeoJSONData::create(const GeoJSON& geoJSON, Immutab clusterOptions.maxZoom = options->clusterMaxZoom; clusterOptions.extent = util::EXTENT; clusterOptions.radius = ::round(scale * options->clusterRadius); - Feature feature; - clusterOptions.map = [&, options](const PropertyMap& properties) -> PropertyMap { + auto feature = std::make_shared(); + clusterOptions.map = [feature, options](const PropertyMap& properties) -> PropertyMap { PropertyMap ret{}; if (properties.empty()) return ret; for (const auto& p : options->clusterProperties) { - feature.properties = properties; - ret[p.first] = evaluateFeature(feature, p.second.first); + feature->properties = properties; + ret[p.first] = evaluateFeature(*feature, p.second.first); } return ret; }; - clusterOptions.reduce = [&, options](PropertyMap& toReturn, const PropertyMap& toFill) { + clusterOptions.reduce = [feature, options](PropertyMap& toReturn, const PropertyMap& toFill) { for (const auto& p : options->clusterProperties) { if (toFill.count(p.first) == 0) { continue; } - feature.properties = toFill; + feature->properties = toFill; optional accumulated(toReturn[p.first]); - toReturn[p.first] = evaluateFeature(feature, p.second.second, accumulated); + toReturn[p.first] = evaluateFeature(*feature, p.second.second, accumulated); } }; return std::make_shared(geoJSON.get>(),