summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2018-12-14 14:40:16 -0800
committerGitHub <noreply@github.com>2018-12-14 14:40:16 -0800
commitfed201aaedc1b1c86d6a3bb3a10894fc46cf5628 (patch)
tree992298ace885b2faff4e2ff10d5c4c3153c7bc5a
parent8b7725211eaddcb55e5043a02024736f57618bca (diff)
downloadqtlocation-mapboxgl-fed201aaedc1b1c86d6a3bb3a10894fc46cf5628.tar.gz
[ios, macos] Fix number conversions when expressions cast to large numbers. (#13580)
* [ios, macos] Fix number conversions when expressions cast to large numbers. * [ios, macos] Update changelogs.
-rw-r--r--platform/darwin/src/MGLConversion.h3
-rw-r--r--platform/darwin/test/MGLPredicateTests.mm9
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/macos/CHANGELOG.md1
4 files changed, 12 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLConversion.h b/platform/darwin/src/MGLConversion.h
index 9057ed7824..d6de4151b9 100644
--- a/platform/darwin/src/MGLConversion.h
+++ b/platform/darwin/src/MGLConversion.h
@@ -118,8 +118,7 @@ public:
} else if ( _isString(value)) {
return { *toString(holder) };
} else if (_isNumber(value)) {
- // Need to cast to a double here as the float is otherwise considered a bool...
- return { static_cast<double>(*toNumber(holder)) };
+ return { *toDouble(holder) };
} else {
return {};
}
diff --git a/platform/darwin/test/MGLPredicateTests.mm b/platform/darwin/test/MGLPredicateTests.mm
index ed92c920f6..2ed18d48fc 100644
--- a/platform/darwin/test/MGLPredicateTests.mm
+++ b/platform/darwin/test/MGLPredicateTests.mm
@@ -225,6 +225,15 @@
XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
}
{
+ NSArray *expected = @[@"match", @[@"to-number", @[@"id"]], @[@3002970001, @3004140052, @3002950027, @3002970033], @YES, @NO];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"CAST($featureIdentifier, 'NSNumber') IN { 3002970001, 3004140052, 3002950027, 3002970033 }"];
+ XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
+ NSPredicate *predicateAfter = [NSPredicate predicateWithFormat:@"MGL_MATCH(CAST($featureIdentifier, 'NSNumber'), { 3002950027, 3002970001, 3002970033, 3004140052 }, YES, NO) == YES"];
+ auto forwardFilter = [NSPredicate predicateWithMGLJSONObject:expected].mgl_filter;
+ NSPredicate *forwardPredicateAfter = [NSPredicate mgl_predicateWithFilter:forwardFilter];
+ XCTAssertEqualObjects(predicateAfter, forwardPredicateAfter);
+ }
+ {
NSArray *expected = @[@"!", @[@"match", @[@"get", @"x"], @[@6, @5, @4, @3], @YES, @NO]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT x IN { 6, 5, 4, 3}"];
XCTAssertEqualObjects(predicate.mgl_jsonExpressionObject, expected);
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index ffb4a53cf0..aa1772eb80 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -31,6 +31,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Added `MGLLoggingConfiguration` and `MGLLoggingBlockHandler` that handle error and fault events produced by the SDK. ([#13235](https://github.com/mapbox/mapbox-gl-native/pull/13235))
* Fixed random crashes during app termination. ([#13367](https://github.com/mapbox/mapbox-gl-native/pull/13367))
* Fixed a crash when specifying MGLShapeSourceOptionLineDistanceMetrics when creating an MGLShapeSource. ([#13543](https://github.com/mapbox/mapbox-gl-native/pull/13543))
+* Fixed a crash when casting large numbers in `NSExpression`. ([#13580](https://github.com/mapbox/mapbox-gl-native/pull/13580))
## 4.6.0 - November 7, 2018
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md
index 3c1ffdd188..c9fe738d4d 100644
--- a/platform/macos/CHANGELOG.md
+++ b/platform/macos/CHANGELOG.md
@@ -19,6 +19,7 @@
* `MGLMapSnapshotter` now respects the `MGLIdeographicFontFamilyName` key in Info.plist, which reduces bandwidth consumption when snapshotting regions that contain Chinese or Japanese characters. ([#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427))
* Added `MGLLoggingConfiguration` and `MGLLoggingBlockHandler` that handle error and fault events produced by the SDK. ([#13235](https://github.com/mapbox/mapbox-gl-native/pull/13235))
* Fixed a crash when specifying MGLShapeSourceOptionLineDistanceMetrics when creating an MGLShapeSource. ([#13543](https://github.com/mapbox/mapbox-gl-native/pull/13543))
+* Fixed a crash when casting large numbers in `NSExpression`. ([#13580](https://github.com/mapbox/mapbox-gl-native/pull/13580))s
## 0.12.0 - November 8, 2018