]> granicus.if.org Git - handbrake/commitdiff
MacGui: fix a leak of the output log file path string.
authorritsuka <damiog@gmail.com>
Sat, 10 Jan 2015 08:38:37 +0000 (08:38 +0000)
committerritsuka <damiog@gmail.com>
Sat, 10 Jan 2015 08:38:37 +0000 (08:38 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6719 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBOutputPanelController.h
macosx/HBOutputPanelController.m

index 5843ab1dad93e8d2ccca8ba6de9382a9f1af3071..14ab72dee79bcfcb26989a61c871168dc490b1bf 100644 (file)
  * 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;
index fd003b034be455ce974b3bdff968746a18366511..d924df80a4cdb87b15ae30a4fd0ddfee589284ff 100644 (file)
 #define TextStorageLowerSizeLimit 120000
 
 @interface HBOutputPanelController () <HBOutputRedirectListening>
+{
+    /// 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
     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
     {
                                             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];
 
 
 }
     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);
     }