Skip to content
Snippets Groups Projects
Commit 33a5698c authored by George Nachman's avatar George Nachman
Browse files

Fix a crash on 10.9 and earlier when tabs don't have close buttons and the...

Fix a crash on 10.9 and earlier when tabs don't have close buttons and the titles are long. Issue 4985
parent dbd520ff
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -22,17 +22,16 @@ static const CGFloat kPSMTabBarCellBaselineOffset = 14.5;
@implementation NSAttributedString(PSM)
 
- (NSAttributedString *)attributedStringWithTextAlignment:(NSTextAlignment)textAlignment {
// First try to do it the easy way.
if (self.length == 0) {
return self;
}
NSDictionary *immutableAttributes = [self attributesAtIndex:0 effectiveRange:nil];
NSMutableParagraphStyle *paragraphStyle = immutableAttributes[NSParagraphStyleAttributeName];
if ([paragraphStyle isKindOfClass:[NSMutableParagraphStyle class]]) {
paragraphStyle.alignment = textAlignment;
if (!immutableAttributes) {
return self;
}
// If that fails do it the right way.
NSMutableDictionary *attributes = [[immutableAttributes mutableCopy] autorelease];
paragraphStyle = [[attributes[NSParagraphStyleAttributeName] mutableCopy] autorelease];
NSMutableParagraphStyle *paragraphStyle = [[attributes[NSParagraphStyleAttributeName] mutableCopy] autorelease];
if (!paragraphStyle) {
paragraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment