diff --git a/src/MacVim/PSMTabBarControl/source/PSMAquaTabStyle.h b/src/MacVim/PSMTabBarControl/source/PSMAquaTabStyle.h index 06540dac1a..e8229570ec 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMAquaTabStyle.h +++ b/src/MacVim/PSMTabBarControl/source/PSMAquaTabStyle.h @@ -22,6 +22,8 @@ NSImage *_addTabButtonImage; NSImage *_addTabButtonPressedImage; NSImage *_addTabButtonRolloverImage; + NSMutableParagraphStyle *truncatingTailParagraphStyle; + NSMutableParagraphStyle *centeredParagraphStyle; } - (void)loadImages; diff --git a/src/MacVim/PSMTabBarControl/source/PSMAquaTabStyle.m b/src/MacVim/PSMTabBarControl/source/PSMAquaTabStyle.m index 849c072599..dba0250a98 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMAquaTabStyle.m +++ b/src/MacVim/PSMTabBarControl/source/PSMAquaTabStyle.m @@ -74,6 +74,9 @@ [_addTabButtonImage release]; [_addTabButtonPressedImage release]; [_addTabButtonRolloverImage release]; + + [truncatingTailParagraphStyle release]; + [centeredParagraphStyle release]; [super dealloc]; } @@ -283,13 +286,12 @@ [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; // Paragraph Style for Truncating Long Text - static NSMutableParagraphStyle *TruncatingTailParagraphStyle = nil; - if (!TruncatingTailParagraphStyle) { - TruncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; - [TruncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; - [TruncatingTailParagraphStyle setAlignment:NSCenterTextAlignment]; + if (!truncatingTailParagraphStyle) { + truncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; + [truncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; + [truncatingTailParagraphStyle setAlignment:NSCenterTextAlignment]; } - [attrStr addAttribute:NSParagraphStyleAttributeName value:TruncatingTailParagraphStyle range:range]; + [attrStr addAttribute:NSParagraphStyleAttributeName value:truncatingTailParagraphStyle range:range]; return attrStr; } @@ -371,7 +373,6 @@ attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; NSRange range = NSMakeRange(0, [contents length]); [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; - NSMutableParagraphStyle *centeredParagraphStyle = nil; if (!centeredParagraphStyle) { centeredParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; [centeredParagraphStyle setAlignment:NSCenterTextAlignment]; diff --git a/src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.h b/src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.h index 0cbdb1ee85..20bf7e0bfd 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.h +++ b/src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.h @@ -16,6 +16,8 @@ NSImage *_addTabButtonImage; NSImage *_addTabButtonPressedImage; NSImage *_addTabButtonRolloverImage; + NSMutableParagraphStyle *truncatingTailParagraphStyle; + NSMutableParagraphStyle *centeredParagraphStyle; } - (void)drawInteriorWithTabCell:(PSMTabBarCell *)cell inView:(NSView*)controlView; diff --git a/src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.m b/src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.m index 2b2bce45c2..31134804ec 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.m +++ b/src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.m @@ -59,6 +59,9 @@ void MyNSDrawWindowBackground(NSRect rect) [_addTabButtonImage release]; [_addTabButtonPressedImage release]; [_addTabButtonRolloverImage release]; + + [truncatingTailParagraphStyle release]; + [centeredParagraphStyle release]; [super dealloc]; } @@ -297,13 +300,12 @@ void MyNSDrawWindowBackground(NSRect rect) [attrStr addAttribute:NSShadowAttributeName value:shadow range:range]; // Paragraph Style for Truncating Long Text - static NSMutableParagraphStyle *TruncatingTailParagraphStyle = nil; - if (!TruncatingTailParagraphStyle) { - TruncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; - [TruncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; - [TruncatingTailParagraphStyle setAlignment:NSCenterTextAlignment]; + if (!truncatingTailParagraphStyle) { + truncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; + [truncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; + [truncatingTailParagraphStyle setAlignment:NSCenterTextAlignment]; } - [attrStr addAttribute:NSParagraphStyleAttributeName value:TruncatingTailParagraphStyle range:range]; + [attrStr addAttribute:NSParagraphStyleAttributeName value:truncatingTailParagraphStyle range:range]; return attrStr; } @@ -477,7 +479,6 @@ void MyNSDrawWindowBackground(NSRect rect) attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; NSRange range = NSMakeRange(0, [contents length]); [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; - NSMutableParagraphStyle *centeredParagraphStyle = nil; if (!centeredParagraphStyle) { centeredParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; [centeredParagraphStyle setAlignment:NSCenterTextAlignment]; diff --git a/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m b/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m index c71793ba16..121912f354 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m +++ b/src/MacVim/PSMTabBarControl/source/PSMTabBarCell.m @@ -324,7 +324,7 @@ if(([self state] == NSOnState) && ([[_controlView styleName] isEqualToString:@"Metal"])) cellFrame.size.width += 1.0; [_controlView lockFocus]; - NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:cellFrame]; + NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:cellFrame] autorelease]; [_controlView unlockFocus]; NSImage *image = [[[NSImage alloc] initWithSize:[rep size]] autorelease]; [image addRepresentation:rep]; diff --git a/src/MacVim/PSMTabBarControl/source/PSMUnifiedTabStyle.h b/src/MacVim/PSMTabBarControl/source/PSMUnifiedTabStyle.h index 751956aaed..871f713c52 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMUnifiedTabStyle.h +++ b/src/MacVim/PSMTabBarControl/source/PSMUnifiedTabStyle.h @@ -17,6 +17,8 @@ NSImage *_addTabButtonImage; NSImage *_addTabButtonPressedImage; NSImage *_addTabButtonRolloverImage; + NSMutableParagraphStyle *truncatingTailParagraphStyle; + NSMutableParagraphStyle *centeredParagraphStyle; float leftMargin; } diff --git a/src/MacVim/PSMTabBarControl/source/PSMUnifiedTabStyle.m b/src/MacVim/PSMTabBarControl/source/PSMUnifiedTabStyle.m index 3a5a35fe87..2bd59762f8 100644 --- a/src/MacVim/PSMTabBarControl/source/PSMUnifiedTabStyle.m +++ b/src/MacVim/PSMTabBarControl/source/PSMUnifiedTabStyle.m @@ -53,6 +53,8 @@ [_addTabButtonImage release]; [_addTabButtonPressedImage release]; [_addTabButtonRolloverImage release]; + [truncatingTailParagraphStyle release]; + [centeredParagraphStyle release]; [super dealloc]; } @@ -268,12 +270,11 @@ [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; // Paragraph Style for Truncating Long Text - static NSMutableParagraphStyle *TruncatingTailParagraphStyle = nil; - if (!TruncatingTailParagraphStyle) { - TruncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; - [TruncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; + if (!truncatingTailParagraphStyle) { + truncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; + [truncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; } - [attrStr addAttribute:NSParagraphStyleAttributeName value:TruncatingTailParagraphStyle range:range]; + [attrStr addAttribute:NSParagraphStyleAttributeName value:truncatingTailParagraphStyle range:range]; return attrStr; } @@ -472,7 +473,6 @@ attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; NSRange range = NSMakeRange(0, [contents length]); [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; - NSMutableParagraphStyle *centeredParagraphStyle = nil; if (!centeredParagraphStyle) { centeredParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; [centeredParagraphStyle setAlignment:NSCenterTextAlignment];