Authored by Justin R. Miller

closes #290: merge in parts of @RubioV/RMMapBoxSource-offline-crash-fix

@@ -67,16 +67,10 @@ static RMConfiguration *RMConfigurationSharedInstance = nil; @@ -67,16 +67,10 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
67 67
68 [request setValue:[[RMConfiguration configuration] userAgent] forHTTPHeaderField:@"User-Agent"]; 68 [request setValue:[[RMConfiguration configuration] userAgent] forHTTPHeaderField:@"User-Agent"];
69 69
70 - NSError *internalError = nil;  
71 -  
72 - NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&internalError]; 70 + NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:error];
73 71
74 if ( ! returnData) 72 if ( ! returnData)
75 - {  
76 - *error = internalError;  
77 -  
78 return nil; 73 return nil;
79 - }  
80 74
81 return [[[self class] alloc] initWithData:returnData encoding:enc]; 75 return [[[self class] alloc] initWithData:returnData encoding:enc];
82 } 76 }
@@ -117,13 +111,13 @@ static RMConfiguration *RMConfigurationSharedInstance = nil; @@ -117,13 +111,13 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
117 111
118 RMLog(@"reading route-me configuration from %@", path); 112 RMLog(@"reading route-me configuration from %@", path);
119 113
120 - NSString *error = nil; 114 + NSError *error = nil;
121 NSData *plistData = [NSData dataWithContentsOfFile:path]; 115 NSData *plistData = [NSData dataWithContentsOfFile:path];
122 116
123 - _propertyList = [NSPropertyListSerialization propertyListFromData:plistData  
124 - mutabilityOption:NSPropertyListImmutable 117 + _propertyList = [NSPropertyListSerialization propertyListWithData:plistData
  118 + options:NSPropertyListImmutable
125 format:NULL 119 format:NULL
126 - errorDescription:&error]; 120 + error:&error];
127 121
128 if ( ! _propertyList) 122 if ( ! _propertyList)
129 { 123 {
@@ -79,6 +79,8 @@ @@ -79,6 +79,8 @@
79 _infoDictionary = (NSDictionary *)[NSJSONSerialization JSONObjectWithData:[tileJSON dataUsingEncoding:NSUTF8StringEncoding] 79 _infoDictionary = (NSDictionary *)[NSJSONSerialization JSONObjectWithData:[tileJSON dataUsingEncoding:NSUTF8StringEncoding]
80 options:0 80 options:0
81 error:nil]; 81 error:nil];
  82 + if ( ! _infoDictionary)
  83 + return nil;
82 84
83 _tileJSON = tileJSON; 85 _tileJSON = tileJSON;
84 86
@@ -174,7 +176,8 @@ @@ -174,7 +176,8 @@
174 176
175 - (void)dealloc 177 - (void)dealloc
176 { 178 {
177 - dispatch_release(_dataQueue); 179 + if (_dataQueue)
  180 + dispatch_release(_dataQueue);
178 } 181 }
179 182
180 #pragma mark 183 #pragma mark