From 58962687fd345782a012a8a4412627c691db522f Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 26 Aug 2009 06:36:50 +0000 Subject: =?UTF-8?q?=E2=80=A2=20bug=20fixed=20for=20providing=20an=20auto-g?= =?UTF-8?q?enerated=20name=20for=20favorites=20after=20redesign=20-=20not?= =?UTF-8?q?=20every=20favorite=20query=20is=20longer=20than=2032=20charact?= =?UTF-8?q?ers=20thus=20check=20length=20in=20beforehand=20to=20avoid=20ra?= =?UTF-8?q?ising=20an=20exception=20which=20causes=20that=20SP=20doesn't?= =?UTF-8?q?=20start?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPPreferenceController.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/SPPreferenceController.m') diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index d27234d7..938accdc 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -280,7 +280,8 @@ if (([favorite isKindOfClass:[NSDictionary class]]) && ([favorite objectForKey:@"name"]) && ([favorite objectForKey:@"query"])) continue; // By default make the query's name the first 32 characters of the query with '...' appended - NSString *favoriteName = [[[favorite stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]] substringToIndex:32] stringByAppendingString:@"..."]; + int idx = ( [favorite length] > 32 ) ? 32 : [favorite length]; + NSString *favoriteName = [[[favorite stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]] substringToIndex:idx] stringByAppendingString:@"..."]; [queryFavoritesArray replaceObjectAtIndex:i withObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:favoriteName, favorite, nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]]]; } -- cgit v1.2.3