Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-11334] Fixing Geolocation crasher. #3145

Merged
merged 3 commits into from
Oct 12, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES == YES ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats wrong with explicitly checking the value of a boolean? or is there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it against our styling guide

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