diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-02-06 10:16:14 -0800 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2018-02-07 12:11:19 -0800 |
commit | 057af7e75f78a7a8ddd12e4df0f1bd688eaf31fa (patch) | |
tree | 41868c9a518856ab216352475b98a16c0f0f9899 /src | |
parent | 638ab799eda3d8eb474fb248469914f12e6a957a (diff) | |
download | qtlocation-mapboxgl-057af7e75f78a7a8ddd12e4df0f1bd688eaf31fa.tar.gz |
[core] Don't crash on line labels with 0 glyphs.
Fixes issue #10956.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/layout/symbol_projection.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/mbgl/layout/symbol_projection.cpp b/src/mbgl/layout/symbol_projection.cpp index 279d251f8f..d97bfb1ac0 100644 --- a/src/mbgl/layout/symbol_projection.cpp +++ b/src/mbgl/layout/symbol_projection.cpp @@ -271,7 +271,7 @@ namespace mbgl { placedGlyphs.push_back(*placedGlyph); } placedGlyphs.push_back(*lastPlacedGlyph); - } else { + } else if (symbol.glyphOffsets.size() == 1) { // Only a single glyph to place // So, determine whether to flip based on projected angle of the line segment it's on if (keepUpright && !flip) { @@ -289,7 +289,6 @@ namespace mbgl { return PlacementResult::NeedsFlipping; } } - assert(symbol.glyphOffsets.size() == 1); // We are relying on SymbolInstance.hasText filtering out symbols without any glyphs at all const float glyphOffsetX = symbol.glyphOffsets.front(); optional<PlacedGlyph> singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetX, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, symbol.segment, symbol.line, labelPlaneMatrix); @@ -299,6 +298,8 @@ namespace mbgl { placedGlyphs.push_back(*singleGlyph); } + // The number of placedGlyphs must equal the number of glyphOffsets, which must correspond to the number of glyph vertices + // There may be 0 glyphs here, if a label consists entirely of glyphs that have 0x0 dimensions for (auto& placedGlyph : placedGlyphs) { addDynamicAttributes(placedGlyph.point, placedGlyph.angle, symbol.placementZoom, dynamicVertexArray); } |