From 344cd173ea96b2812549b980d1ab725c0aae57f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Tue, 17 Jan 2017 22:12:52 -0800 Subject: [macos] Avoid nilling out style URL on load -awakeFromNib nils out the styleURL property to ensure a style is always present on load. However, if the style URL is specified in the Style URL inspectable, it is set somewhere between -initWithCoder: and -awakeFromNib; nilling out the styleURL property in -awakeFromNib thus resets the style to the default. This change guards against nilling out a non-nil style URL, ensuring that -setStyleURL: is called once and only once on launch. --- platform/macos/src/MGLMapView.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 00fb5e3b23..3deb7db577 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -231,7 +231,11 @@ public: - (void)awakeFromNib { [super awakeFromNib]; - self.styleURL = nil; + // If the Style URL inspectable was not set, make sure to go through + // -setStyleURL: to load the default style. + if (_mbglMap->getStyleURL().empty()) { + self.styleURL = nil; + } } + (NSArray *)restorableStateKeyPaths { -- cgit v1.2.1