[core] Check all bucket dynamic_casts
A mismatch can occur when a layer changes from one type to another.
This commit is contained in:
@@ -4,6 +4,7 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to
|
||||
|
||||
## master
|
||||
- Token string syntax (`"{token}"`) in `SymbolLayer` `textField` and `iconImage` property values is now correctly converted to the appropriate expression equivalent. ([#11659](https://github.com/mapbox/mapbox-gl-native/issues/11659))
|
||||
- Fixed a crash when switching between two styles having layers with the same identifier but different layer types. ([#12432](https://github.com/mapbox/mapbox-gl-native/issues/12432))
|
||||
|
||||
## 6.3.0 - July 18, 2018
|
||||
- Harden map events creation [#12406](https://github.com/mapbox/mapbox-gl-native/pull/12406)
|
||||
|
||||
@@ -9,6 +9,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
|
||||
* Fixed a crash that occurred when the user started a gesture before the drift animation for a previous gesture was complete. ([#12148](https://github.com/mapbox/mapbox-gl-native/pull/12148))
|
||||
* Token string syntax (`"{token}"`) in `MGLSymbolStyleLayer` `text` and `iconImageName` properties is now correctly converted to the appropriate `NSExpression` equivalent. ([#11659](https://github.com/mapbox/mapbox-gl-native/issues/11659))
|
||||
* Added an `MGLMapView.locationManager` property and `MGLLocationManager` protocol for tracking user location using a custom alternative to `CLLocationManager`. ([#12013](https://github.com/mapbox/mapbox-gl-native/pull/12013))
|
||||
* Fixed a crash when switching between two styles having layers with the same identifier but different layer types. ([#12432](https://github.com/mapbox/mapbox-gl-native/issues/12432))
|
||||
|
||||
|
||||
## 4.2.0 - July 18, 2018
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
## Styles and rendering
|
||||
|
||||
* Token string syntax (`"{token}"`) in `MGLSymbolStyleLayer` `text` and `iconImageName` properties is now correctly converted to the appropriate `NSExpression` equivalent. ([#11659](https://github.com/mapbox/mapbox-gl-native/issues/11659))
|
||||
* Fixed a crash when switching between two styles having layers with the same identifier but different layer types. ([#12432](https://github.com/mapbox/mapbox-gl-native/issues/12432))
|
||||
|
||||
# 0.9.0 - July 18, 2018
|
||||
|
||||
|
||||
@@ -56,8 +56,11 @@ void RenderCircleLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
const bool pitchWithMap = evaluated.get<CirclePitchAlignment>() == AlignmentType::Map;
|
||||
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<CircleBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
CircleBucket& bucket = *reinterpret_cast<CircleBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<CircleBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
CircleBucket& bucket = *bucket_;
|
||||
|
||||
const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
|
||||
|
||||
|
||||
@@ -100,9 +100,11 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
|
||||
|
||||
if (evaluated.get<FillExtrusionPattern>().from.empty()) {
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
FillExtrusionBucket& bucket =
|
||||
*reinterpret_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
FillExtrusionBucket& bucket = *bucket_;
|
||||
|
||||
draw(
|
||||
parameters.programs.fillExtrusion.get(evaluated),
|
||||
@@ -129,9 +131,11 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
|
||||
parameters.imageManager.bind(parameters.context, 0);
|
||||
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
FillExtrusionBucket& bucket =
|
||||
*reinterpret_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
FillExtrusionBucket& bucket = *bucket_;
|
||||
|
||||
draw(
|
||||
parameters.programs.fillExtrusionPattern.get(evaluated),
|
||||
|
||||
@@ -61,8 +61,11 @@ bool RenderFillLayer::hasTransition() const {
|
||||
void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
if (evaluated.get<FillPattern>().from.empty()) {
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
FillBucket& bucket = *reinterpret_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
FillBucket& bucket = *bucket_;
|
||||
|
||||
auto draw = [&] (auto& program,
|
||||
const auto& drawMode,
|
||||
@@ -146,8 +149,11 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
parameters.imageManager.bind(parameters.context, 0);
|
||||
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
FillBucket& bucket = *reinterpret_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
FillBucket& bucket = *bucket_;
|
||||
|
||||
auto draw = [&] (auto& program,
|
||||
const auto& drawMode,
|
||||
|
||||
@@ -83,8 +83,11 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
parameters.context.clear(Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {});
|
||||
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
HeatmapBucket& bucket = *reinterpret_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
HeatmapBucket& bucket = *bucket_;
|
||||
|
||||
const auto extrudeScale = tile.id.pixelsToTileUnits(1, parameters.state.getZoom());
|
||||
|
||||
|
||||
@@ -114,8 +114,12 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src
|
||||
matrix::translate(mat, mat, 0, -util::EXTENT, 0);
|
||||
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<HillshadeBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
HillshadeBucket& bucket = *reinterpret_cast<HillshadeBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<HillshadeBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
HillshadeBucket& bucket = *bucket_;
|
||||
|
||||
if (!bucket.hasData()){
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,11 @@ void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
}
|
||||
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<LineBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
LineBucket& bucket = *reinterpret_cast<LineBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<LineBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
LineBucket& bucket = *bucket_;
|
||||
|
||||
auto draw = [&] (auto& program, auto&& uniformValues) {
|
||||
auto& programInstance = program.get(evaluated);
|
||||
|
||||
@@ -142,8 +142,11 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
|
||||
}
|
||||
} else {
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<RasterBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
RasterBucket& bucket = *reinterpret_cast<RasterBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<RasterBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
RasterBucket& bucket = *bucket_;
|
||||
|
||||
if (!bucket.hasData())
|
||||
continue;
|
||||
|
||||
@@ -75,8 +75,11 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
}
|
||||
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
assert(dynamic_cast<SymbolBucket*>(tile.tile.getBucket(*baseImpl)));
|
||||
SymbolBucket& bucket = *reinterpret_cast<SymbolBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
auto bucket_ = dynamic_cast<SymbolBucket*>(tile.tile.getBucket(*baseImpl));
|
||||
if (!bucket_) {
|
||||
continue;
|
||||
}
|
||||
SymbolBucket& bucket = *bucket_;
|
||||
|
||||
const auto& layout = bucket.layout;
|
||||
|
||||
|
||||
@@ -178,9 +178,12 @@ bool CrossTileSymbolIndex::addLayer(RenderSymbolLayer& symbolLayer, float lng) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto bucket = renderTile.tile.getBucket(*symbolLayer.baseImpl);
|
||||
assert(dynamic_cast<SymbolBucket*>(bucket));
|
||||
SymbolBucket& symbolBucket = *reinterpret_cast<SymbolBucket*>(bucket);
|
||||
auto bucket = dynamic_cast<SymbolBucket*>(renderTile.tile.getBucket(*symbolLayer.baseImpl));
|
||||
if (!bucket) {
|
||||
continue;
|
||||
}
|
||||
SymbolBucket& symbolBucket = *bucket;
|
||||
|
||||
if (symbolBucket.bucketLeaderID != symbolLayer.getID()) {
|
||||
// Only add this layer if it's the "group leader" for the bucket
|
||||
continue;
|
||||
|
||||
@@ -50,12 +50,13 @@ void Placement::placeLayer(RenderSymbolLayer& symbolLayer, const mat4& projMatri
|
||||
}
|
||||
assert(dynamic_cast<GeometryTile*>(&renderTile.tile));
|
||||
GeometryTile& geometryTile = static_cast<GeometryTile&>(renderTile.tile);
|
||||
|
||||
|
||||
auto bucket = geometryTile.getBucket(*symbolLayer.baseImpl);
|
||||
assert(dynamic_cast<SymbolBucket*>(bucket));
|
||||
SymbolBucket& symbolBucket = *reinterpret_cast<SymbolBucket*>(bucket);
|
||||
|
||||
|
||||
auto bucket = dynamic_cast<SymbolBucket*>(geometryTile.getBucket(*symbolLayer.baseImpl));
|
||||
if (!bucket) {
|
||||
continue;
|
||||
}
|
||||
SymbolBucket& symbolBucket = *bucket;
|
||||
|
||||
if (symbolBucket.bucketLeaderID != symbolLayer.getID()) {
|
||||
// Only place this layer if it's the "group leader" for the bucket
|
||||
continue;
|
||||
@@ -231,9 +232,12 @@ void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto bucket = renderTile.tile.getBucket(*symbolLayer.baseImpl);
|
||||
assert(dynamic_cast<SymbolBucket*>(bucket));
|
||||
SymbolBucket& symbolBucket = *reinterpret_cast<SymbolBucket*>(bucket);
|
||||
auto bucket = dynamic_cast<SymbolBucket*>(renderTile.tile.getBucket(*symbolLayer.baseImpl));
|
||||
if (!bucket) {
|
||||
continue;
|
||||
}
|
||||
SymbolBucket& symbolBucket = *bucket;
|
||||
|
||||
if (symbolBucket.bucketLeaderID != symbolLayer.getID()) {
|
||||
// Only update opacities this layer if it's the "group leader" for the bucket
|
||||
continue;
|
||||
|
||||
BIN
test/fixtures/map/issue12432/0-0-0.mvt
vendored
Normal file
BIN
test/fixtures/map/issue12432/0-0-0.mvt
vendored
Normal file
Binary file not shown.
@@ -653,3 +653,52 @@ TEST(Map, NoContentTiles) {
|
||||
0.0015,
|
||||
0.1);
|
||||
}
|
||||
|
||||
// https://github.com/mapbox/mapbox-gl-native/issues/12432
|
||||
TEST(Map, Issue12432) {
|
||||
MapTest<> test { 1, MapMode::Continuous };
|
||||
|
||||
test.fileSource.tileResponse = [&](const Resource&) {
|
||||
Response result;
|
||||
result.data = std::make_shared<std::string>(util::read_file("test/fixtures/map/issue12432/0-0-0.mvt"));
|
||||
return result;
|
||||
};
|
||||
|
||||
test.map.getStyle().loadJSON(R"STYLE({
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"type": "vector",
|
||||
"tiles": ["http://example.com/{z}-{x}-{y}.vector.pbf"]
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "water",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "water"
|
||||
}]
|
||||
})STYLE");
|
||||
|
||||
test.observer.didFinishLoadingMapCallback = [&]() {
|
||||
test.map.getStyle().loadJSON(R"STYLE({
|
||||
"version": 8,
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"type": "vector",
|
||||
"tiles": ["http://example.com/{z}-{x}-{y}.vector.pbf"]
|
||||
}
|
||||
},
|
||||
"layers": [{
|
||||
"id": "water",
|
||||
"type": "line",
|
||||
"source": "mapbox",
|
||||
"source-layer": "water"
|
||||
}]
|
||||
})STYLE");
|
||||
|
||||
test.runLoop.stop();
|
||||
};
|
||||
|
||||
test.runLoop.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user