summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2019-04-04 20:02:42 -0700
committerFabian Guerra <fabian.guerra@mapbox.com>2019-04-04 20:02:42 -0700
commit87eeee9231aa8b59df92181ebe51d6b1ff0df431 (patch)
treeb77cc8ddd71b63a7ba7e208b8ea0f204b1cd9198
parentfab134ba361900b11a7f51adc00621ece912b2df (diff)
downloadqtlocation-mapboxgl-upstream/fabian-format-crash.tar.gz
Branch to reproduce the format expression crash.upstream/fabian-format-crash
-rw-r--r--platform/darwin/src/MGLStyleValue_Private.h2
-rw-r--r--platform/ios/app/MBXViewController.m29
-rw-r--r--platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme7
3 files changed, 34 insertions, 4 deletions
diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h
index fee34b4b71..269b1eed5e 100644
--- a/platform/darwin/src/MGLStyleValue_Private.h
+++ b/platform/darwin/src/MGLStyleValue_Private.h
@@ -86,7 +86,7 @@ public:
return mbglValue;
}
- NSArray *jsonExpression = expression.mgl_jsonExpressionObject;
+ NSArray *jsonExpression = @[ @"format", @"foo", @{ @"text-color": @[@"rgb", @255, @0, @0] } ];
mbgl::style::conversion::Error valueError;
auto value = mbgl::style::conversion::convert<MBGLValue>(
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 8d936d6a25..4fa37668a1 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -1115,8 +1115,33 @@ CLLocationCoordinate2D randomWorldCoordinate() {
- (void)styleSymbolLayer
{
- MGLSymbolStyleLayer *stateLayer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:@"state-label-lg"];
- stateLayer.textColor = [NSExpression expressionForConstantValue:[UIColor redColor]];
+ MGLSymbolStyleLayer *stateLayer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:@"state-label"];
+
+ MGLAttributedExpression *firstRowAttribute = [MGLAttributedExpression attributedExpression:[NSExpression expressionForKeyPath:@"name"]
+ fontNames:nil
+ fontScale:nil];
+ MGLAttributedExpression *lineBreak = [MGLAttributedExpression attributedExpression:[NSExpression expressionForConstantValue:@"\n"]
+ fontNames:nil
+ fontScale:nil];
+ NSExpression *fontNames = [NSExpression expressionForAggregate:@[ [NSExpression expressionForConstantValue:@"Arial Unicode MS Bold"] ]];
+ MGLAttributedExpression *formatAttribute = [MGLAttributedExpression attributedExpression:[NSExpression expressionForKeyPath:@"name"]
+ attributes:@{ MGLFontScaleAttribute :
+ [NSExpression expressionForConstantValue:@(0.8)],
+ MGLFontColorAttribute :
+ [NSExpression expressionForConstantValue:@"blue"],
+ MGLFontNamesAttribute :
+ fontNames
+ }];
+
+ NSExpression *attributedExpression = [NSExpression expressionWithFormat:@"mgl_attributed:(%@, %@, %@)",
+ [NSExpression expressionForConstantValue:firstRowAttribute],
+ [NSExpression expressionForConstantValue:lineBreak],
+ [NSExpression expressionForConstantValue:formatAttribute]
+ ];
+
+ NSExpression * expression = [NSExpression expressionWithFormat:@"MGL_MATCH(2 - 1, 1, %@, 'Foo')", attributedExpression];
+
+ stateLayer.text = expression;
}
- (void)styleBuildingLayer
diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme
index 1f8969faf7..8a57a564dd 100644
--- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme
+++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme
@@ -42,7 +42,7 @@
</AdditionalOptions>
</TestAction>
<LaunchAction
- buildConfiguration = "Debug"
+ buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
@@ -62,6 +62,11 @@
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
+ <AdditionalOption
+ key = "NSZombieEnabled"
+ value = "YES"
+ isEnabled = "YES">
+ </AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction