summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-04-18 17:44:24 -0700
committerChris Loer <chris.loer@mapbox.com>2018-04-19 10:47:51 -0700
commitb414c607c3369641fca23c79dfaff231a66a89cf (patch)
treed94ff2a15352f2a846bc70eed87a54b6730e0acf /src
parent29e23cf08b4315cfa0777c6962f06376e2bdee60 (diff)
downloadqtlocation-mapboxgl-b414c607c3369641fca23c79dfaff231a66a89cf.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/layout/symbol_instance.cpp4
-rw-r--r--src/mbgl/layout/symbol_projection.cpp6
2 files changed, 8 insertions, 2 deletions
diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp
index 6e152349ca..7dfa8edf43 100644
--- a/src/mbgl/layout/symbol_instance.cpp
+++ b/src/mbgl/layout/symbol_instance.cpp
@@ -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;
diff --git a/src/mbgl/layout/symbol_projection.cpp b/src/mbgl/layout/symbol_projection.cpp
index 9e077e2532..ef669c6e19 100644
--- a/src/mbgl/layout/symbol_projection.cpp
+++ b/src/mbgl/layout/symbol_projection.cpp
@@ -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();;