session_handle does not need to be a global variable in the prefs controller

This commit is contained in:
Mitchell Livingston 2012-05-29 01:03:21 +00:00
parent 4ddc3582d0
commit c1f2085715
4 changed files with 8 additions and 20 deletions

View File

@ -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];

View File

@ -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;

View File

@ -29,6 +29,7 @@
@interface PrefsController : NSWindowController <NSToolbarDelegate>
{
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;

View File

@ -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)