Skip to content

Commit

Permalink
Merge pull request #3145 from srahim/timob-11334
Browse files Browse the repository at this point in the history
[TIMOB-11334] Fixing Geolocation crasher.
  • Loading branch information
Max Stepanov committed Oct 12, 2012
2 parents 3e6c6e3 + a151cd0 commit 0586fb4
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,9 @@ -(void)getCurrentPosition:(id)callback
{
ENSURE_SINGLE_ARG(callback,KrollCallback);
ENSURE_UI_THREAD(getCurrentPosition,callback);
if (singleLocation==nil)
{
singleLocation = [[NSMutableArray alloc] initWithCapacity:1];
}


// If the location updates are started, invoke the callback directly.
if (locationManager!=nil && trackingLocation==YES) {
if (locationManager != nil && locationManager.location != nil && trackingLocation == YES ) {
CLLocation *currentLocation = locationManager.location;
NSDictionary *todict = [self locationDictionary:currentLocation];
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:
Expand All @@ -535,6 +531,10 @@ -(void)getCurrentPosition:(id)callback
}
// Otherwise, start the location manager.
else {
if (singleLocation==nil)
{
singleLocation = [[NSMutableArray alloc] initWithCapacity:1];
}
[singleLocation addObject:callback];
[self startStopLocationManagerIfNeeded];
}
Expand Down Expand Up @@ -846,7 +846,15 @@ -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
[self locationManager:manager didUpdateLocations:[NSArray arrayWithObjects:oldLocation,newLocation,nil]];
if (newLocation != nil) {
if (oldLocation == nil) {
[self locationManager:manager didUpdateLocations:[NSArray arrayWithObject:newLocation]];
}
else{
[self locationManager:manager didUpdateLocations:[NSArray arrayWithObjects:oldLocation,newLocation,nil]];
}
}

}


Expand Down

0 comments on commit 0586fb4

Please sign in to comment.