From f4c56bb02798ebfbbaba7e7f182843b72f276264 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 11 Dec 2010 12:42:00 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fix=20table=20name=20encoding=20problem=20(?= =?UTF-8?q?return=20name=20can=20be=20NSNull)=20which=20can=20arise=20whil?= =?UTF-8?q?e=20SPTablesList=20updateTables=20method,=20=E2=80=A2=20added?= =?UTF-8?q?=20[theView=20breakUndoCoalescing];=20before=20inserting=20the?= =?UTF-8?q?=20grey=20completion=20suggestion=20due=20to=20possible=20undo?= =?UTF-8?q?=20exceptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPNarrowDownCompletion.m | 1 + Source/SPTablesList.m | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'Source') diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 81f4e28b..f86c66c5 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -953,6 +953,7 @@ NSString* toInsert = [curMatch substringFromIndex:[originalFilterString length]]; theCharRange.length += [toInsert length] - currentAutocompleteLength; theParseRange.length += [toInsert length]; + [theView breakUndoCoalescing]; [theView insertText:[toInsert lowercaseString]]; autocompletePlaceholderWasInserted = YES; diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index bbc40164..54e0f400 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -106,7 +106,14 @@ } else { for ( i = 0 ; i < [theResult numOfRows] ; i++ ) { resultRow = [theResult fetchRowAsArray]; - NSString *tableName = [NSString stringWithUTF8String:[[resultRow objectAtIndex:0] cStringUsingEncoding:[mySQLConnection stringEncoding]]]; + // Due to encoding problems it can be the case that [resultRow objectAtIndex:0] + // return NSNull, thus catch that case for safety reasons + NSString *row = [resultRow objectAtIndex:0]; + NSString *tableName; + if([row isKindOfClass:[NSString class]]) + tableName = [NSString stringWithUTF8String:[row cStringUsingEncoding:[mySQLConnection stringEncoding]]]; + else + tableName = @"..."; [tables addObject:tableName]; if ([[resultRow objectAtIndex:1] isEqualToString:@"VIEW"]) { [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeView]]; -- cgit v1.2.3