diff --git a/Classes/SBAppDelegate.m b/Classes/SBAppDelegate.m index 7757abe..0702614 100755 --- a/Classes/SBAppDelegate.m +++ b/Classes/SBAppDelegate.m @@ -25,7 +25,11 @@ [SBPrefsController registerUserDefaults]; - debugLogController = [[SBDebugLogController alloc] init]; + NSString *path = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, + NSUserDomainMask, + YES) firstObject] stringByAppendingPathComponent:@"Subler/debugLog.txt"]; + + debugLogController = [[SBDebugLogController alloc] initWithLogFile:[NSURL fileURLWithPath:path]]; [MP42File redirectLogUsingBlock:^(NSString *text) { [debugLogController log:text]; diff --git a/Classes/SBDebugLogController.h b/Classes/SBDebugLogController.h index 2f8d3ba..5f844ff 100644 --- a/Classes/SBDebugLogController.h +++ b/Classes/SBDebugLogController.h @@ -9,9 +9,11 @@ #import @interface SBDebugLogController : NSWindowController { - NSTextView *logView; + NSTextView *_logView; + NSURL *_fileURL; } +- (instancetype)initWithLogFile:(NSURL *)fileURL; - (void)log:(NSString *)string; @end diff --git a/Classes/SBDebugLogController.m b/Classes/SBDebugLogController.m index e2050c8..aa355ef 100644 --- a/Classes/SBDebugLogController.m +++ b/Classes/SBDebugLogController.m @@ -11,14 +11,16 @@ @interface SBDebugLogController () @property (assign) IBOutlet NSTextView *logView; +@property (readonly) NSURL *fileURL; @end @implementation SBDebugLogController -@synthesize logView; -- (instancetype)init -{ +@synthesize logView = _logView; +@synthesize fileURL = _fileURL; + +- (instancetype)init { if ((self = [super initWithWindowNibName:@"SBDebugLogWindow"])) { [self window]; } @@ -26,12 +28,24 @@ return self; } +- (instancetype)initWithLogFile:(NSURL *)fileURL { + self = [self init]; -- (void)windowDidLoad { - [super windowDidLoad]; + if (self) { + _fileURL = [fileURL copy]; + [[NSFileManager defaultManager] removeItemAtURL:_fileURL error:nil]; + } + + return self; } - (void)log:(NSString *)string { + if (self.fileURL) { + FILE *f = fopen([self.fileURL fileSystemRepresentation], "a"); + fprintf(f, "%s", [string UTF8String]); + fclose(f); + } + dispatch_async(dispatch_get_main_queue(), ^{ NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:string]; [[self.logView textStorage] appendAttributedString:attributedString]; diff --git a/Classes/SBDocument.m b/Classes/SBDocument.m index 061b7cd..a88dd9c 100755 --- a/Classes/SBDocument.m +++ b/Classes/SBDocument.m @@ -943,6 +943,9 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn [propertyView release]; propertyView = nil; + [fileTracksTable setDelegate:nil]; + [fileTracksTable setDataSource:nil]; + [languages release]; languages = nil; diff --git a/English.lproj/SBDebugLogWindow.xib b/English.lproj/SBDebugLogWindow.xib index 5cc4673..7f104b4 100644 --- a/English.lproj/SBDebugLogWindow.xib +++ b/English.lproj/SBDebugLogWindow.xib @@ -16,7 +16,7 @@ - + @@ -30,7 +30,7 @@ - +