summaryrefslogtreecommitdiff
path: root/src/mbgl/text
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-07-23 16:08:44 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-07-24 11:08:40 -0700
commit2bbc79206073d260863c887a95ee4ba25bc45910 (patch)
tree4478ba0db1d873ed35e80b7e342100d85728ed18 /src/mbgl/text
parentcb714d57c5c5ad181aaf5e1690221da8d965682b (diff)
downloadqtlocation-mapboxgl-2bbc79206073d260863c887a95ee4ba25bc45910.tar.gz
[core] Check all bucket dynamic_casts
A mismatch can occur when a layer changes from one type to another.
Diffstat (limited to 'src/mbgl/text')
-rw-r--r--src/mbgl/text/cross_tile_symbol_index.cpp9
-rw-r--r--src/mbgl/text/placement.cpp22
2 files changed, 19 insertions, 12 deletions
diff --git a/src/mbgl/text/cross_tile_symbol_index.cpp b/src/mbgl/text/cross_tile_symbol_index.cpp
index 8df26ca117..58dcda46f5 100644
--- a/src/mbgl/text/cross_tile_symbol_index.cpp
+++ b/src/mbgl/text/cross_tile_symbol_index.cpp
@@ -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;
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index fd0710d959..96c1873e33 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -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;