Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

prevent crash when expression evaluates to default, no pattern #12896

Merged
merged 1 commit into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/mbgl/renderer/paint_property_binder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,17 @@ class CompositeCrossFadedPaintPropertyBinder : public PaintPropertyBinder<T, std
};

void populateVertexVector(const GeometryTileFeature&, std::size_t length, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies) override {
if (!patternDependencies) return;
if (!patternPositions.empty()) {

if (patternDependencies->mid.empty()) {
// Unlike other propperties with expressions that evaluate to null, the default value for `*-pattern` properties is an empty
// string and will not have a valid entry in patternPositions. We still need to populate the attribute buffers to avoid crashes
// when we try to draw the layer because we don't know at draw time if all features were evaluated to valid pattern dependencies.
for (std::size_t i = zoomInVertexVector.vertexSize(); i < length; ++i) {
patternToVertexVector.emplace_back(Vertex { std::array<uint16_t, 4>{{0, 0, 0, 0}} });
zoomInVertexVector.emplace_back(Vertex2 { std::array<uint16_t, 4>{{0, 0, 0, 0}} } );
zoomOutVertexVector.emplace_back(Vertex2 { std::array<uint16_t, 4>{{0, 0, 0, 0}} });
}
} else if (!patternPositions.empty()) {
const auto min = patternPositions.find(patternDependencies->min);
const auto mid = patternPositions.find(patternDependencies->mid);
const auto max = patternPositions.find(patternDependencies->max);
Expand Down