fix some memory leaks in the file and peer table cells

This commit is contained in:
Mitchell Livingston
2008-01-07 00:07:03 +00:00
parent 1e45d3e478
commit 0f87a52a30
4 changed files with 63 additions and 36 deletions
+4 -4
View File
@@ -2888,6 +2888,10 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[segmentedControl setSegmentCount: 2];
[segmentedCell setTrackingMode: NSSegmentSwitchTrackingMomentary];
NSSize groupSize = NSMakeSize(72.0, 25.0);
[groupItem setMinSize: groupSize];
[groupItem setMaxSize: groupSize];
[groupItem setLabel: NSLocalizedString(@"Apply All", "All toolbar item -> label")];
[groupItem setPaletteLabel: NSLocalizedString(@"Pause / Resume All", "All toolbar item -> palette label")];
[groupItem setTarget: self];
@@ -2908,10 +2912,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause All", "All toolbar item -> label"),
NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
NSSize groupSize = NSMakeSize(72.0, 25.0);
[groupItem setMinSize: groupSize];
[groupItem setMaxSize: groupSize];
[segmentedControl release];
return [groupItem autorelease];
}
+41 -24
View File
@@ -47,6 +47,47 @@
@implementation FileNameCell
- (id) init
{
if ((self = [super init]))
{
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
fTitleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[NSFont messageFontOfSize: 12.0], NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
[paragraphStyle release];
}
return self;
}
- (void) dealloc
{
[fTitleAttributes release];
[fStatusAttributes release];
[fFolderImage release];
[super dealloc];
}
- (id) copyWithZone: (NSZone *) zone
{
FileNameCell * copy = [super copyWithZone: zone];
copy->fTitleAttributes = [fTitleAttributes retain];
copy->fStatusAttributes = [fStatusAttributes retain];
copy->fFolderImage = [fFolderImage retain];
return copy;
}
- (NSImage *) image
{
NSImage * image = [[self objectValue] objectForKey: @"Icon"];
@@ -159,18 +200,6 @@
- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color
{
if (!fTitleAttributes)
{
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
fTitleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[NSFont messageFontOfSize: 12.0], NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
[paragraphStyle release];
}
if (color)
[fTitleAttributes setObject: color forKey: NSForegroundColorAttributeName];
@@ -180,18 +209,6 @@
- (NSAttributedString *) attributedStatusWithColor: (NSColor *) color
{
if (!fStatusAttributes)
{
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
[paragraphStyle release];
}
if (color)
[fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName];
-1
View File
@@ -28,7 +28,6 @@
{
BOOL fIsHidden;
NSDictionary * fAttributes;
NSImage * fCheckImage;
}
@end
+18 -7
View File
@@ -26,6 +26,20 @@
@implementation PeerProgressIndicatorCell
- (id) copyWithZone: (NSZone *) zone
{
PeerProgressIndicatorCell * copy = [super copyWithZone: zone];
copy->fAttributes = [fAttributes retain];
return copy;
}
- (void) dealloc
{
[fAttributes release];
[super dealloc];
}
- (BOOL) hidden
{
return fIsHidden;
@@ -58,16 +72,13 @@
[super drawWithFrame: cellFrame inView: controlView];
if ([self floatValue] >= 1.0)
{
if (!fCheckImage)
{
fCheckImage = [NSImage imageNamed: @"CompleteCheck.png"];
[fCheckImage setFlipped: YES];
}
NSImage * checkImage = [NSImage imageNamed: @"CompleteCheck.png"];
[checkImage setFlipped: YES];
NSSize imageSize = [fCheckImage size];
NSSize imageSize = [checkImage size];
NSRect rect = NSMakeRect(cellFrame.origin.x + (cellFrame.size.width - imageSize.width) * 0.5,
cellFrame.origin.y + (cellFrame.size.height - imageSize.height) * 0.5, imageSize.width, imageSize.height);
[fCheckImage drawInRect: rect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
[checkImage drawInRect: rect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
}
}
}