aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPPreferenceController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-26 06:36:50 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-26 06:36:50 +0000
commit58962687fd345782a012a8a4412627c691db522f (patch)
tree6d0cb27eef85d13f37960a1d7f422ec9aa9a6c6d /Source/SPPreferenceController.m
parent91353b0b04f55c467af3b221e72816cabdf22d70 (diff)
downloadsequelpro-58962687fd345782a012a8a4412627c691db522f.tar.gz
sequelpro-58962687fd345782a012a8a4412627c691db522f.tar.bz2
sequelpro-58962687fd345782a012a8a4412627c691db522f.zip
• bug fixed for providing an auto-generated name for favorites after redesign
- not every favorite query is longer than 32 characters thus check length in beforehand to avoid raising an exception which causes that SP doesn't start
Diffstat (limited to 'Source/SPPreferenceController.m')
-rw-r--r--Source/SPPreferenceController.m3
1 files changed, 2 insertions, 1 deletions
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]]];
}