From 71e4a6fcb9389808a09d2f16598e9f554da7622c Mon Sep 17 00:00:00 2001 From: ritsuka Date: Sat, 10 Jan 2015 08:38:37 +0000 Subject: MacGui: fix a leak of the output log file path string. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6719 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/HBOutputPanelController.h | 13 ------------- macosx/HBOutputPanelController.m | 28 +++++++++++++++++++++------- 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'macosx') diff --git a/macosx/HBOutputPanelController.h b/macosx/HBOutputPanelController.h index 5843ab1da..14ab72dee 100644 --- a/macosx/HBOutputPanelController.h +++ b/macosx/HBOutputPanelController.h @@ -12,19 +12,6 @@ * to stderr. User can easily copy the text to pasteboard from context menu. */ @interface HBOutputPanelController : NSWindowController -{ - /// Textview that displays debug output. - IBOutlet NSTextView *textView; - - /// Text storage for the debug output. - NSTextStorage *outputTextStorage; - - /// Path to log text file. - NSString *outputLogFile; - /// Path to individual log text file. - NSString *outputLogFileForEncode; - BOOL encodeLogOn; -} - (IBAction)showOutputPanel:(id)sender; - (IBAction)clearOutput:(id)sender; diff --git a/macosx/HBOutputPanelController.m b/macosx/HBOutputPanelController.m index fd003b034..d924df80a 100644 --- a/macosx/HBOutputPanelController.m +++ b/macosx/HBOutputPanelController.m @@ -23,6 +23,21 @@ #define TextStorageLowerSizeLimit 120000 @interface HBOutputPanelController () +{ + /// Textview that displays debug output. + IBOutlet NSTextView *textView; + + /// Text storage for the debug output. + NSTextStorage *outputTextStorage; + + /// Path to log text file. + NSString *outputLogFile; + BOOL encodeLogOn; +} + +/// Path to individual log text file. +@property (nonatomic, copy) NSString *outputLogFileForEncode; + @end @implementation HBOutputPanelController @@ -135,8 +150,7 @@ NSString *outputDateFileName = [NSString stringWithFormat:@"%@ %@.txt",[[outputFileForEncode lastPathComponent] stringByDeletingPathExtension],dateForLogTitle]; if ([[NSUserDefaults standardUserDefaults] boolForKey:@"EncodeLogLocation"]) // if we are putting it in the same directory with the movie { - - outputLogFileForEncode = [[NSString stringWithFormat:@"%@/%@",[outputFileForEncode stringByDeletingLastPathComponent],outputDateFileName] retain]; + self.outputLogFileForEncode = [NSString stringWithFormat:@"%@/%@",[outputFileForEncode stringByDeletingLastPathComponent], outputDateFileName]; } else // if we are putting it in the default ~/Libraries/Application Support/HandBrake/EncodeLogs logs directory { @@ -148,14 +162,14 @@ attributes:nil error:nil]; } - outputLogFileForEncode = [[NSString stringWithFormat:@"%@/%@",encodeLogDirectory,outputDateFileName] retain]; + self.outputLogFileForEncode = [NSString stringWithFormat:@"%@/%@",encodeLogDirectory,outputDateFileName]; } - [fileManager createFileAtPath:outputLogFileForEncode contents:nil attributes:nil]; + [fileManager createFileAtPath:self.outputLogFileForEncode contents:nil attributes:nil]; /* Similar to the regular activity log, we print a header containing the date and time of the encode as well as what directory it was encoded to */ NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)\n\n", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]]; NSString *startOutputLogString = [NSString stringWithFormat: @"HandBrake Activity Log for %@: %@\n%@",outputFileForEncode, [[NSDate date] descriptionWithCalendarFormat:nil timeZone:nil locale:nil],versionStringFull]; - [startOutputLogString writeToFile:outputLogFileForEncode atomically:YES encoding:NSUTF8StringEncoding error:NULL]; + [startOutputLogString writeToFile:self.outputLogFileForEncode atomically:YES encoding:NSUTF8StringEncoding error:NULL]; } @@ -189,9 +203,9 @@ fprintf(f, "%s", [text UTF8String]); fclose(f); - if (encodeLogOn == YES && outputLogFileForEncode != nil) + if (encodeLogOn == YES && self.outputLogFileForEncode != nil) { - FILE *e = fopen([outputLogFileForEncode UTF8String], "a"); + FILE *e = fopen([self.outputLogFileForEncode UTF8String], "a"); fprintf(e, "%s", [text UTF8String]); fclose(e); } -- cgit v1.2.3