Manos Chorianopoulos

handle db open

......@@ -4991,6 +4991,20 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
// [self initDBIfNeeded];
// [self restore];
BOOL dbOpened = NO;
@try {
@synchronized (_DatabaseLock) {
dbOpened = [_db open];
}
}
@catch (NSException *exception) {
NSLog(@"Open db error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
BOOL tableExist = NO;
@try {
@synchronized (_DatabaseLock) {
......@@ -5007,7 +5021,7 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
time_t timestamp = (time_t) [[NSDate date] timeIntervalSince1970];
// NSString *accessToken = [NSString alloc];
NSString *accessToken = @"";
if (([_db open] == YES) && (tableExist == YES)) {
if ((dbOpened == YES) && (tableExist == YES)) {
// FMResultSet *accessTokenSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"];
// while ([accessTokenSet next]) {
// accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
......@@ -5165,6 +5179,19 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
// [self initDBIfNeeded];
// [self restore];
BOOL dbOpened = NO;
@try {
@synchronized (_DatabaseLock) {
dbOpened = [_db open];
}
}
@catch (NSException *exception) {
NSLog(@"Open db error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
BOOL tableExist = NO;
@try {
@synchronized (_DatabaseLock) {
......@@ -5181,7 +5208,7 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
time_t timestamp = (time_t) [[NSDate date] timeIntervalSince1970];
// NSString *accessToken = [NSString alloc];
NSString *accessToken = @"";
if (([_db open] == YES) && (tableExist == YES)) {
if ((dbOpened == YES) && (tableExist == YES)) {
@try {
@synchronized (_DatabaseLock) {
FMResultSet *accessTokenSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"];
......