From b5f8fa76b54e16448de8e723240daf8159860d6d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 9 Jul 2009 00:40:25 +0000 Subject: - Add a number of additional nil checks as protection against further recurrences of Issue #331 --- Source/TableDocument.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 42d1309d..d6758112 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -270,7 +270,7 @@ if([[self user] length]) [connection setValue:[self user] forKey:@"username"]; [connection setValue:[self host] forKey:@"hostname"]; - if([[connectionController port] length]) + if([connectionController port] &&[[connectionController port] length]) [connection setValue:[connectionController port] forKey:@"port"]; [connection setValue:selectedDatabase forKey:@"database"]; [connection setValue:versionForPrint forKey:@"version"]; @@ -1290,7 +1290,9 @@ - (NSString *)host { if ([connectionController type] == SP_CONNECTION_SOCKET) return @"localhost"; - return [connectionController host]; + NSString theHost = [connectionController host]; + if (!theHost) theHost = @""; + return theHost; } /** @@ -1298,13 +1300,13 @@ */ - (NSString *)name { - if ([[connectionController name] length]) { + if ([connectionController name] && [[connectionController name] length]) { return [connectionController name]; } if ([connectionController type] == SP_CONNECTION_SOCKET) { - return [NSString stringWithFormat:@"%@@%@", [connectionController user], [connectionController host]]; + return [NSString stringWithFormat:@"%@@localhost", [connectionController user]?[connectionController user]:@""]; } - return [NSString stringWithFormat:@"%@@%@", [connectionController user], [connectionController host]]; + return [NSString stringWithFormat:@"%@@%@", [connectionController user]?[connectionController user]:@"", [connectionController host]?[connectionController host]:@""]; } /** @@ -1336,7 +1338,9 @@ */ - (NSString *)user { - return [connectionController user]; + NSString theUser = [connectionController user]; + if (!theUser) theUser = @""; + return theUser; } #pragma mark - -- cgit v1.2.3