From 8ddf4e5beafde2fb2956de866737640cd62b717b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ciar=C3=A1n=20Walsh?= Date: Wed, 25 Jun 2008 01:01:25 +0100 Subject: [PATCH] A few miscellaneous memory management fixes * Source/BSSourceView.m: (setFile:): Autorelease the NSTask and release the NSAttributedString * Source/BSSplitView.m: (drawDividerInRect:): Release the NSGradient after drawing * Source/Breakpoint.m: (initWithDictionary:): Retain the file object * Source/BreakpointManager.m: (hasBreakpointAtLine:inFile:): Autorelease the object we send to [containsObject:] --- Source/BSSourceView.m | 3 ++- Source/BSSplitView.m | 1 + Source/Breakpoint.m | 2 +- Source/BreakpointManager.m | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/BSSourceView.m b/Source/BSSourceView.m index 69a1364..4dcd8b6 100644 --- a/Source/BSSourceView.m +++ b/Source/BSSourceView.m @@ -60,7 +60,7 @@ { // Attempt to use the PHP CLI to highlight the source file as HTML NSPipe* pipe = [NSPipe pipe]; - NSTask* task = [NSTask new]; + NSTask* task = [[NSTask new] autorelease]; [task setLaunchPath:@"/usr/bin/php"]; // This is the path to the default Leopard PHP executable [task setArguments:[NSArray arrayWithObjects:@"-s", f, nil]]; [task setStandardOutput:pipe]; @@ -68,6 +68,7 @@ NSData* data = [[pipe fileHandleForReading] readDataToEndOfFile]; NSAttributedString* source = [[NSAttributedString alloc] initWithHTML:data documentAttributes:NULL]; [[textView textStorage] setAttributedString:source]; + [source release]; } @catch (NSException* exception) { diff --git a/Source/BSSplitView.m b/Source/BSSplitView.m index 957bbe2..1221c52 100644 --- a/Source/BSSplitView.m +++ b/Source/BSSplitView.m @@ -31,6 +31,7 @@ NSColor *endColor = [NSColor colorWithDeviceRed:0.812 green:0.812 blue:0.812 alpha:1.0]; NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor]; [gradient drawInRect:rect angle:([self isVertical] ? 0.0 : 90.0)]; + [gradient release]; // draw the stroke [[NSColor colorWithDeviceRed:0.667 green:0.667 blue:0.667 alpha:1.0] setStroke]; diff --git a/Source/Breakpoint.m b/Source/Breakpoint.m index ff04fe5..460d35d 100644 --- a/Source/Breakpoint.m +++ b/Source/Breakpoint.m @@ -50,7 +50,7 @@ { if (self = [super init]) { - file = [dict valueForKey:@"file"]; + file = [[dict valueForKey:@"file"] retain]; line = [[dict valueForKey:@"line"] intValue]; } return self; diff --git a/Source/BreakpointManager.m b/Source/BreakpointManager.m index a592959..5a53155 100644 --- a/Source/BreakpointManager.m +++ b/Source/BreakpointManager.m @@ -107,7 +107,7 @@ */ - (BOOL)hasBreakpointAt:(int)line inFile:(NSString *)file { - return [breakpoints containsObject:[[Breakpoint alloc] initWithLine:line inFile:file]]; + return [breakpoints containsObject:[[[Breakpoint alloc] initWithLine:line inFile:file] autorelease]]; } #pragma mark Private -- 2.43.5