diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-31 16:36:23 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-31 16:36:23 +0000 |
commit | 097d8ea042e9545bce160fa3001d53fc74611537 (patch) | |
tree | eebd03dd2686d239f4f33671f2a85ce3e3f25540 | |
parent | fd9839fa73309ed9f1471be2032907f4e49b69da (diff) | |
download | sequelpro-097d8ea042e9545bce160fa3001d53fc74611537.tar.gz sequelpro-097d8ea042e9545bce160fa3001d53fc74611537.tar.bz2 sequelpro-097d8ea042e9545bce160fa3001d53fc74611537.zip |
check for the attributed string length >= 3 while truncating it to avoid exceptions
-rw-r--r-- | Source/SPFavoriteTextFieldCell.m | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Source/SPFavoriteTextFieldCell.m b/Source/SPFavoriteTextFieldCell.m index 1ef39348..f9025f63 100644 --- a/Source/SPFavoriteTextFieldCell.m +++ b/Source/SPFavoriteTextFieldCell.m @@ -152,7 +152,7 @@ if (maxWidth < mainStringWidth) { for (i = 0; i <= [mainString length]; i++) { - if ([[mainString attributedSubstringFromRange:NSMakeRange(0, i)] size].width >= maxWidth) { + if ([[mainString attributedSubstringFromRange:NSMakeRange(0, i)] size].width >= maxWidth && i >= 3) { mainString = [[[NSMutableAttributedString alloc] initWithString:[[[mainString attributedSubstringFromRange:NSMakeRange(0, i - 3)] string] stringByAppendingString:@"..."] attributes:[self mainStringAttributedStringAttributes]] autorelease]; } } @@ -160,7 +160,7 @@ if (maxWidth < subStringWidth) { for (i = 0; i <= [subString length]; i++) { - if ([[subString attributedSubstringFromRange:NSMakeRange(0, i)] size].width >= maxWidth) { + if ([[subString attributedSubstringFromRange:NSMakeRange(0, i)] size].width >= maxWidth && i >= 3) { subString = [[[NSMutableAttributedString alloc] initWithString:[[[subString attributedSubstringFromRange:NSMakeRange(0, i - 3)] string] stringByAppendingString:@"..."] attributes:[self subStringAttributedStringAttributes]] autorelease]; } } |