Remove redutant statements.

This commit is contained in:
Dzmitry Neviadomski 2021-01-18 05:52:38 +03:00
parent 18266e080e
commit e5bff86ae7
5 changed files with 43 additions and 69 deletions

View File

@ -239,7 +239,6 @@ static void removeKeRangerRansomware()
NSMutableArray * fTorrents, * fDisplayedTorrents; NSMutableArray * fTorrents, * fDisplayedTorrents;
PrefsController * fPrefsController;
InfoWindowController * fInfoController; InfoWindowController * fInfoController;
MessageWindowController * fMessageController; MessageWindowController * fMessageController;
@ -252,8 +251,6 @@ static void removeKeRangerRansomware()
io_connect_t fRootPort; io_connect_t fRootPort;
NSTimer * fTimer; NSTimer * fTimer;
VDKQueue * fFileWatcherQueue;
StatusBarController * fStatusBar; StatusBarController * fStatusBar;
FilterBarController * fFilterBar; FilterBarController * fFilterBar;
@ -279,10 +276,6 @@ static void removeKeRangerRansomware()
BOOL fSoundPlaying; BOOL fSoundPlaying;
} }
@synthesize prefsController = fPrefsController;
@synthesize messageWindowController = fMessageController;
@synthesize fileWatcherQueue = fFileWatcherQueue;
+ (void) initialize + (void) initialize
{ {
removeKeRangerRansomware(); removeKeRangerRansomware();
@ -485,10 +478,10 @@ static void removeKeRangerRansomware()
fInfoController = [[InfoWindowController alloc] init]; fInfoController = [[InfoWindowController alloc] init];
//needs to be done before init-ing the prefs controller //needs to be done before init-ing the prefs controller
fFileWatcherQueue = [[VDKQueue alloc] init]; _fileWatcherQueue = [[VDKQueue alloc] init];
[fFileWatcherQueue setDelegate: self]; [_fileWatcherQueue setDelegate: self];
fPrefsController = [[PrefsController alloc] initWithHandle: fLib]; _prefsController = [[PrefsController alloc] initWithHandle: fLib];
fQuitting = NO; fQuitting = NO;
fGlobalPopoverShown = NO; fGlobalPopoverShown = NO;
@ -860,7 +853,7 @@ static void removeKeRangerRansomware()
[self updateTorrentHistory]; [self updateTorrentHistory];
[fTableView saveCollapsedGroups]; [fTableView saveCollapsedGroups];
fFileWatcherQueue = nil; _fileWatcherQueue = nil;
//complete cleanup //complete cleanup
tr_sessionClose(fLib); tr_sessionClose(fLib);
@ -1842,7 +1835,7 @@ static void removeKeRangerRansomware()
- (void) showPreferenceWindow: (id) sender - (void) showPreferenceWindow: (id) sender
{ {
NSWindow * window = [fPrefsController window]; NSWindow * window = [_prefsController window];
if (![window isVisible]) if (![window isVisible])
[window center]; [window center];
@ -4675,7 +4668,7 @@ static void removeKeRangerRansomware()
break; break;
case TR_RPC_SESSION_CHANGED: case TR_RPC_SESSION_CHANGED:
[fPrefsController rpcUpdatePrefs]; [_prefsController rpcUpdatePrefs];
break; break;
case TR_RPC_SESSION_CLOSE: case TR_RPC_SESSION_CLOSE:

View File

@ -30,32 +30,17 @@
@implementation FileListNode @implementation FileListNode
{ {
NSMutableIndexSet * fIndexes; NSMutableIndexSet * _indexes;
NSImage * _icon;
NSString * fName; NSMutableArray * _children;
NSString * fPath;
Torrent * __weak fTorrent;
uint64_t fSize;
NSImage * fIcon;
BOOL fIsFolder;
NSMutableArray * fChildren;
} }
@synthesize name = fName;
@synthesize path = fPath;
@synthesize torrent = fTorrent;
@synthesize size = fSize;
@synthesize icon = fIcon;
@synthesize isFolder = fIsFolder;
@synthesize indexes = fIndexes;
@synthesize children = fChildren;
- (id) initWithFolderName: (NSString *) name path: (NSString *) path torrent: (Torrent *) torrent - (id) initWithFolderName: (NSString *) name path: (NSString *) path torrent: (Torrent *) torrent
{ {
if ((self = [self initWithFolder: YES name: name path: path torrent: torrent])) if ((self = [self initWithFolder: YES name: name path: path torrent: torrent]))
{ {
fChildren = [[NSMutableArray alloc] init]; _children = [[NSMutableArray alloc] init];
fSize = 0; _size = 0;
} }
return self; return self;
@ -65,8 +50,8 @@
{ {
if ((self = [self initWithFolder: NO name: name path: path torrent: torrent])) if ((self = [self initWithFolder: NO name: name path: path torrent: torrent]))
{ {
fSize = size; _size = size;
[fIndexes addIndex: index]; [_indexes addIndex: index];
} }
return self; return self;
@ -74,17 +59,17 @@
- (void) insertChild: (FileListNode *) child - (void) insertChild: (FileListNode *) child
{ {
NSAssert(fIsFolder, @"method can only be invoked on folders"); NSAssert(_isFolder, @"method can only be invoked on folders");
[fChildren addObject: child]; [_children addObject: child];
} }
- (void) insertIndex: (NSUInteger) index withSize: (uint64_t) size - (void) insertIndex: (NSUInteger) index withSize: (uint64_t) size
{ {
NSAssert(fIsFolder, @"method can only be invoked on folders"); NSAssert(_isFolder, @"method can only be invoked on folders");
[fIndexes addIndex: index]; [_indexes addIndex: index];
fSize += size; _size += size;
} }
- (id) copyWithZone: (NSZone *) zone - (id) copyWithZone: (NSZone *) zone
@ -96,25 +81,30 @@
- (NSString *) description - (NSString *) description
{ {
if (!fIsFolder) if (!_isFolder)
return [NSString stringWithFormat: @"%@ (%ld)", fName, [fIndexes firstIndex]]; return [NSString stringWithFormat: @"%@ (%ld)", _name, [_indexes firstIndex]];
else else
return [NSString stringWithFormat: @"%@ (folder: %@)", fName, fIndexes]; return [NSString stringWithFormat: @"%@ (folder: %@)", _name, _indexes];
} }
- (NSImage *) icon - (NSImage *) icon
{ {
if (!fIcon) if (!_icon)
fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fIsFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon) _icon = [[NSWorkspace sharedWorkspace] iconForFileType: _isFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
: [fName pathExtension]]; : [_name pathExtension]];
return fIcon; return _icon;
} }
- (NSMutableArray *) children - (NSMutableArray *) children
{ {
NSAssert(fIsFolder, @"method can only be invoked on folders"); NSAssert(_isFolder, @"method can only be invoked on folders");
return fChildren; return _children;
}
- (NSIndexSet *) indexes
{
return _indexes;
} }
- (BOOL) updateFromOldName: (NSString *) oldName toNewName: (NSString *) newName inPath: (NSString *) path - (BOOL) updateFromOldName: (NSString *) oldName toNewName: (NSString *) newName inPath: (NSString *) path
@ -130,8 +120,8 @@
{ {
if ([oldName isEqualToString: self.name]) if ([oldName isEqualToString: self.name])
{ {
fName = [newName copy]; _name = [newName copy];
fIcon = nil; _icon = nil;
return YES; return YES;
} }
} }
@ -147,7 +137,7 @@
NSString * oldPathPrefix = [path stringByAppendingPathComponent: oldName]; NSString * oldPathPrefix = [path stringByAppendingPathComponent: oldName];
NSString * newPathPrefix = [path stringByAppendingPathComponent: newName]; NSString * newPathPrefix = [path stringByAppendingPathComponent: newName];
fPath = [fPath stringByReplacingCharactersInRange: NSMakeRange(0, [oldPathPrefix length]) withString: newPathPrefix]; _path = [_path stringByReplacingCharactersInRange: NSMakeRange(0, [oldPathPrefix length]) withString: newPathPrefix];
return YES; return YES;
} }
} }
@ -163,13 +153,13 @@
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
fIsFolder = isFolder; _isFolder = isFolder;
fName = [name copy]; _name = [name copy];
fPath = [path copy]; _path = [path copy];
fIndexes = [[NSMutableIndexSet alloc] init]; _indexes = [[NSMutableIndexSet alloc] init];
fTorrent = torrent; _torrent = torrent;
} }
return self; return self;

View File

@ -23,12 +23,6 @@ typedef void (^CompletionBlock)(BOOL);
@end @end
@implementation FileRenameSheetController @implementation FileRenameSheetController
{
Torrent * _torrent;
FileListNode * _node;
void (^_completionHandler)(BOOL);
NSString * _originalName;
}
+ (void) presentSheetForTorrent: (Torrent *) torrent modalForWindow: (NSWindow *) window completionHandler: (void (^)(BOOL didRename)) completionHandler + (void) presentSheetForTorrent: (Torrent *) torrent modalForWindow: (NSWindow *) window completionHandler: (void (^)(BOOL didRename)) completionHandler
{ {

View File

@ -105,6 +105,7 @@
//set auto import //set auto import
NSString * autoPath; NSString * autoPath;
VDKQueue* x = [(Controller *)[NSApp delegate] fileWatcherQueue];
if ([fDefaults boolForKey: @"AutoImport"] && (autoPath = [fDefaults stringForKey: @"AutoImportDirectory"])) if ([fDefaults boolForKey: @"AutoImport"] && (autoPath = [fDefaults stringForKey: @"AutoImportDirectory"]))
[[(Controller *)[NSApp delegate] fileWatcherQueue] addPath: [autoPath stringByExpandingTildeInPath] notifyingAbout: VDKQueueNotifyAboutWrite]; [[(Controller *)[NSApp delegate] fileWatcherQueue] addPath: [autoPath stringByExpandingTildeInPath] notifyingAbout: VDKQueueNotifyAboutWrite];

View File

@ -147,8 +147,6 @@ bool trashDataFile(const char * filename, tr_error ** error)
NSIndexSet * fPreviousFinishedIndexes; NSIndexSet * fPreviousFinishedIndexes;
NSDate * fPreviousFinishedIndexesDate; NSDate * fPreviousFinishedIndexesDate;
BOOL fRemoveWhenFinishSeeding;
NSInteger fGroupValue; NSInteger fGroupValue;
TorrentDeterminationType fGroupValueDetermination; TorrentDeterminationType fGroupValueDetermination;
@ -159,8 +157,6 @@ bool trashDataFile(const char * filename, tr_error ** error)
BOOL fTimeMachineExcludeInitialized; BOOL fTimeMachineExcludeInitialized;
} }
@synthesize removeWhenFinishSeeding = fRemoveWhenFinishSeeding;
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (BOOL) torrentDelete - (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (BOOL) torrentDelete
lib: (tr_session *) lib lib: (tr_session *) lib
{ {
@ -257,7 +253,7 @@ bool trashDataFile(const char * filename, tr_error ** error)
@"Active": @([self isActive]), @"Active": @([self isActive]),
@"WaitToStart": @([self waitingToStart]), @"WaitToStart": @([self waitingToStart]),
@"GroupValue": @(fGroupValue), @"GroupValue": @(fGroupValue),
@"RemoveWhenFinishSeeding": @(fRemoveWhenFinishSeeding)}; @"RemoveWhenFinishSeeding": @(_removeWhenFinishSeeding)};
} }
- (void) dealloc - (void) dealloc
@ -1744,7 +1740,7 @@ bool trashDataFile(const char * filename, tr_error ** error)
fGroupValue = [[GroupsController groups] groupIndexForTorrent: self]; fGroupValue = [[GroupsController groups] groupIndexForTorrent: self];
} }
fRemoveWhenFinishSeeding = removeWhenFinishSeeding ? [removeWhenFinishSeeding boolValue] : [fDefaults boolForKey: @"RemoveWhenFinishSeeding"]; _removeWhenFinishSeeding = removeWhenFinishSeeding ? [removeWhenFinishSeeding boolValue] : [fDefaults boolForKey: @"RemoveWhenFinishSeeding"];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:) [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:)
name: @"GroupValueRemoved" object: nil]; name: @"GroupValueRemoved" object: nil];