summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-05-27 12:51:30 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-05-27 12:51:30 -0700
commit86dd0e99bc210f2bdbcd0c4407ec1d7b6074b001 (patch)
treedf156bafb0c6b78ad04013c3b4496511facb9cbe /platform
parentceef4d38419aaa449f543824f7519355ecdf5c94 (diff)
downloadqtlocation-mapboxgl-86dd0e99bc210f2bdbcd0c4407ec1d7b6074b001.tar.gz
Defailablize init methods
If an OpenGL context couldn’t be created, there’s just no point to soldiering on. Things are going to fall apart pretty quickly anyways. Assert and be done with it.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLMapView.mm39
1 files changed, 11 insertions, 28 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index a959bce7bf..a517a4d26f 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -114,41 +114,32 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
- (instancetype)initWithFrame:(CGRect)frame
{
- self = [super initWithFrame:frame];
-
- if (self && [self commonInit])
+ if (self = [super initWithFrame:frame])
{
+ [self commonInit];
self.styleURL = nil;
- return self;
}
-
- return nil;
+ return self;
}
- (instancetype)initWithFrame:(CGRect)frame styleURL:(NSURL *)styleURL
{
- self = [super initWithFrame:frame];
-
- if (self && [self commonInit])
+ if (self = [super initWithFrame:frame])
{
+ [self commonInit];
self.styleURL = styleURL;
- return self;
}
-
- return nil;
+ return self;
}
- (instancetype)initWithCoder:(NSCoder *)decoder
{
- self = [super initWithCoder:decoder];
-
- if (self && [self commonInit])
+ if (self = [super initWithCoder:decoder])
{
+ [self commonInit];
self.styleURL = nil;
- return self;
}
-
- return nil;
+ return self;
}
- (NSString *)accessToken
@@ -193,20 +184,14 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
_mbglMap->setStyleURL([[styleURL absoluteString] UTF8String]);
}
-- (BOOL)commonInit
+- (void)commonInit
{
_isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent;
// create context
//
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
-
- if ( ! _context)
- {
- mbgl::Log::Error(mbgl::Event::Setup, "failed to create OpenGL ES context");
-
- return NO;
- }
+ NSAssert(_context, @"Failed to create OpenGL ES context.");
// setup accessibility
//
@@ -394,8 +379,6 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
MGLEventKeyZoomLevel: @(zoom),
MGLEventKeyPushEnabled: @([MGLMapboxEvents checkPushEnabled])
}];
-
- return YES;
}
-(void)reachabilityChanged:(NSNotification*)notification