summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Thakker <github@anandthakker.net>2018-04-05 15:45:54 -0400
committerAnand Thakker <github@anandthakker.net>2018-04-05 15:45:54 -0400
commit26a461f26e8e7d0584df2d698e2679839cd853be (patch)
treed3113b7b82c3b55f4b3af3119ded67b924f218a6
parent275d753e91501345e00c23166f0c67ccf8741155 (diff)
downloadqtlocation-mapboxgl-26a461f26e8e7d0584df2d698e2679839cd853be.tar.gz
Fix style parsing bug for constant expressions
Closes #10849
-rw-r--r--include/mbgl/style/conversion/data_driven_property_value.hpp14
m---------mapbox-gl-js0
2 files changed, 11 insertions, 3 deletions
diff --git a/include/mbgl/style/conversion/data_driven_property_value.hpp b/include/mbgl/style/conversion/data_driven_property_value.hpp
index 5f4395f35a..466d4b6402 100644
--- a/include/mbgl/style/conversion/data_driven_property_value.hpp
+++ b/include/mbgl/style/conversion/data_driven_property_value.hpp
@@ -46,9 +46,17 @@ struct Converter<DataDrivenPropertyValue<T>> {
} else {
// If an expression is neither zoom- nor feature-dependent, it
// should have been reduced to a Literal when it was parsed.
- auto literal = dynamic_cast<Literal*>(expression->get());
- assert(literal);
- optional<T> constant = fromExpressionValue<T>(literal->getValue());
+ optional<T> constant;
+ if (auto literal = dynamic_cast<Literal*>(expression->get())) {
+ // cool, it's pre-folded to a literal
+ constant = fromExpressionValue<T>(literal->getValue());
+ } else {
+ // we didn't manage to fold to a literal during parsing, so evaluate it now
+ EvaluationContext params(nullptr);
+ EvaluationResult evaluated((*expression)->evaluate(params));
+ assert(evaluated);
+ constant = fromExpressionValue<T>(*evaluated);
+ }
if (!constant) {
return {};
}
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject bbee7e51695184e9b3c0ecb74d314c4ab73d4c2
+Subproject b5839fe06ba186a43685e7ebb2417675d92d099