Don't crash on placing symbols with 0 renderable glyphs

Fixes issue #11729. Close relative of issue #10956.
It is possible for us to receive Glyphs from the server that are valid, but have an invalid bitmap. In that case, the glyphs will be present in the `GlyphMap` used for shaping, but not present in the `GlyphPositions` used in `getGlyphQuads`. `SymbolInstance::hasText` looked at the shaping instead of the actual quads.
`symbol_projection.cpp` should never try to project a label without any quads, but we'll also try to make it so that it doesn't crash if it does.
This commit is contained in:
Chris Loer
2018-04-18 17:44:24 -07:00
committed by Chris Loer
parent 29e23cf08b
commit b414c607c3
2 changed files with 8 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ SymbolInstance::SymbolInstance(Anchor& anchor_,
anchor(anchor_),
line(line_),
index(index_),
hasText(shapedTextOrientations.first || shapedTextOrientations.second),
hasText(false),
hasIcon(shapedIcon),
// Create the collision features that will be used to check whether this symbol instance can be placed
@@ -48,6 +48,8 @@ SymbolInstance::SymbolInstance(Anchor& anchor_,
if (shapedTextOrientations.second) {
verticalGlyphQuads = getGlyphQuads(shapedTextOrientations.second, layout, textPlacement, positions);
}
// 'hasText' depends on finding at least one glyph in the shaping that's also in the GlyphPositionMap
hasText = horizontalGlyphQuads.size() > 0 || verticalGlyphQuads.size() > 0;
if (shapedTextOrientations.first && shapedTextOrientations.second) {
writingModes = WritingModeType::Horizontal | WritingModeType::Vertical;

View File

@@ -240,7 +240,11 @@ namespace mbgl {
const PlacedSymbol& symbol,
const mat4& labelPlaneMatrix,
const bool returnTileDistance) {
if (symbol.glyphOffsets.empty()) {
assert(false);
return optional<std::pair<PlacedGlyph, PlacedGlyph>>();
}
const float firstGlyphOffset = symbol.glyphOffsets.front();
const float lastGlyphOffset = symbol.glyphOffsets.back();;