diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-04-11 20:31:18 +0300 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-14 12:33:13 -0700 |
commit | 98e2e59e5e963dbc5451a19233d942b429a74855 (patch) | |
tree | 2eb68e34823d07a7402e0c633e4c3e9510b76b4c /src/mbgl/text/shaping.cpp | |
parent | 2f4d162debd7e4accfc0b20360058304dce40801 (diff) | |
download | qtlocation-mapboxgl-98e2e59e5e963dbc5451a19233d942b429a74855.tar.gz |
[core] Safeguard PositionedIcon usage via optional
Diffstat (limited to 'src/mbgl/text/shaping.cpp')
-rw-r--r-- | src/mbgl/text/shaping.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index aa760ea4fe..5fae03b4c7 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -10,7 +10,11 @@ namespace mbgl { -PositionedIcon shapeIcon(const SpriteAtlasElement& image, const std::array<float, 2>& iconOffset, const float iconRotation) { +optional<PositionedIcon> PositionedIcon::shapeIcon(const SpriteAtlasElement& image, const std::array<float, 2>& iconOffset, const float iconRotation) { + if (!image.pos.hasArea()) { + return {}; + } + float dx = iconOffset[0]; float dy = iconOffset[1]; float x1 = dx - image.width/ 2.0f; @@ -18,7 +22,7 @@ PositionedIcon shapeIcon(const SpriteAtlasElement& image, const std::array<float float y1 = dy - image.height / 2.0f; float y2 = y1 + image.height; - return PositionedIcon(image, y1, y2, x1, x2, iconRotation); + return { PositionedIcon { image, y1, y2, x1, x2, iconRotation } }; } void align(Shaping& shaping, |