From c1f2085715b52d2525de25003a9d0cbfa734cd04 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 29 May 2012 01:03:21 +0000 Subject: [PATCH] session_handle does not need to be a global variable in the prefs controller --- macosx/BlocklistDownloader.m | 4 ++-- macosx/Controller.m | 3 +-- macosx/PrefsController.h | 4 ++-- macosx/PrefsController.m | 17 +++-------------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/macosx/BlocklistDownloader.m b/macosx/BlocklistDownloader.m index 9d61ef4c1..83ff4c200 100644 --- a/macosx/BlocklistDownloader.m +++ b/macosx/BlocklistDownloader.m @@ -25,7 +25,7 @@ #import "BlocklistDownloader.h" #import "BlocklistDownloaderViewController.h" #import "BlocklistScheduler.h" -#import "PrefsController.h" +#import "Controller.h" @interface BlocklistDownloader (Private) @@ -143,7 +143,7 @@ BlocklistDownloader * fBLDownloader = nil; [self decompressBlocklist]; dispatch_async(dispatch_get_main_queue(), ^{ - const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]); + const int count = tr_blocklistSetContent([(Controller *)[NSApp delegate] sessionHandle], [fDestination UTF8String]); //delete downloaded file [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL]; diff --git a/macosx/Controller.m b/macosx/Controller.m index a20b20886..78e8260ff 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -341,8 +341,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy fInfoController = [[InfoWindowController alloc] init]; - [PrefsController setHandle: fLib]; - fPrefsController = [[PrefsController alloc] init]; + fPrefsController = [[PrefsController alloc] initWithHandle: fLib]; fQuitting = NO; fGlobalPopoverShown = NO; diff --git a/macosx/PrefsController.h b/macosx/PrefsController.h index 50b404726..691420cc3 100644 --- a/macosx/PrefsController.h +++ b/macosx/PrefsController.h @@ -29,6 +29,7 @@ @interface PrefsController : NSWindowController { + tr_session * fHandle; NSUserDefaults * fDefaults; BOOL fHasLoaded; @@ -67,8 +68,7 @@ NSString * fRPCPassword; } -+ (void) setHandle: (tr_session *) handle; -+ (tr_session *) handle; +- (id) initWithHandle: (tr_session *) handle; - (void) setAutoUpdateToBeta: (id) sender; diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index e542efbed..baa6792cc 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -66,23 +66,12 @@ @implementation PrefsController -#warning just call method in Controller? -tr_session * fHandle; -+ (void) setHandle: (tr_session *) handle -{ - fHandle = handle; -} - -#warning elliminate? -+ (tr_session *) handle -{ - return fHandle; -} - -- (id) init +- (id) initWithHandle: (tr_session *) handle { if ((self = [super initWithWindowNibName: @"PrefsWindow"])) { + fHandle = handle; + fDefaults = [NSUserDefaults standardUserDefaults]; //check for old version download location (before 1.1)