summaryrefslogtreecommitdiff
path: root/platform/darwin/src/NSExpression+MGLAdditions.mm
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2019-03-20 10:49:23 -0700
committerGitHub <noreply@github.com>2019-03-20 10:49:23 -0700
commitfc77090fce72448123c4d7d53289e452a378ca7a (patch)
tree8beafeb79800a4759971d0fe85c347afe6c4db18 /platform/darwin/src/NSExpression+MGLAdditions.mm
parent3122df7e5075bb05c99d7033fceb9e561e795874 (diff)
downloadqtlocation-mapboxgl-fc77090fce72448123c4d7d53289e452a378ca7a.tar.gz
[ios, macos] Fix format expression parsing. (#14168)
Fixed a parsing issue when a non-constant expression was passed to MGLAttributedExpression.expression property.
Diffstat (limited to 'platform/darwin/src/NSExpression+MGLAdditions.mm')
-rw-r--r--platform/darwin/src/NSExpression+MGLAdditions.mm18
1 files changed, 5 insertions, 13 deletions
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm
index f0f1d62ef7..091f1edf9d 100644
--- a/platform/darwin/src/NSExpression+MGLAdditions.mm
+++ b/platform/darwin/src/NSExpression+MGLAdditions.mm
@@ -1016,14 +1016,10 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
if ([constantValue isKindOfClass:[MGLAttributedExpression class]]) {
MGLAttributedExpression *attributedExpression = (MGLAttributedExpression *)constantValue;
id jsonObject = attributedExpression.expression.mgl_jsonExpressionObject;
- NSMutableArray *attributes = [NSMutableArray array];
- if ([jsonObject isKindOfClass:[NSArray class]]) {
- [attributes addObjectsFromArray:jsonObject];
- } else {
- [attributes addObject:jsonObject];
- }
+ NSMutableDictionary *attributedDictionary = [NSMutableDictionary dictionary];
+
if (attributedExpression.attributes) {
- NSMutableDictionary *attributedDictionary = [NSMutableDictionary dictionaryWithDictionary:attributedExpression.attributes];
+ attributedDictionary = [NSMutableDictionary dictionaryWithDictionary:attributedExpression.attributes];
if (attributedDictionary[MGLFontNamesAttribute]) {
attributedDictionary[MGLFontNamesAttribute] = @[@"literal", attributedDictionary[MGLFontNamesAttribute]];
}
@@ -1031,12 +1027,8 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
MGLColor *color = attributedDictionary[MGLFontColorAttribute];
attributedDictionary[MGLFontColorAttribute] = color.mgl_jsonExpressionObject;
}
- [attributes addObject:attributedDictionary];
- } else {
- [attributes addObject:@{}];
- }
-
- return attributes;
+ }
+ return @[jsonObject, attributedDictionary];
}
return self.constantValue;
}