]> granicus.if.org Git - transmission/commitdiff
reverse r13248-r13250, since ARC doesn't support 32-bit.
authorMitchell Livingston <livings124@transmissionbt.com>
Tue, 13 Mar 2012 02:52:11 +0000 (02:52 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Tue, 13 Mar 2012 02:52:11 +0000 (02:52 +0000)
71 files changed:
Transmission.xcodeproj/project.pbxproj
macosx/AboutWindowController.m
macosx/AddMagnetWindowController.h
macosx/AddMagnetWindowController.m
macosx/AddWindowController.h
macosx/AddWindowController.m
macosx/BadgeView.m
macosx/Badger.m
macosx/BlocklistDownloader.h
macosx/BlocklistDownloader.m
macosx/BlocklistDownloaderViewController.h
macosx/BlocklistDownloaderViewController.m
macosx/BonjourController.m
macosx/ButtonToolbarItem.h
macosx/ButtonToolbarItem.m
macosx/Controller.h
macosx/Controller.m
macosx/CreatorWindowController.m
macosx/DragOverlayView.m
macosx/DragOverlayWindow.m
macosx/ExpandedPathToIconTransformer.h
macosx/ExpandedPathToPathTransformer.h
macosx/FileListNode.h
macosx/FileListNode.m
macosx/FileNameCell.m
macosx/FileOutlineController.h
macosx/FileOutlineController.m
macosx/FileOutlineView.m
macosx/FilePriorityCell.m
macosx/FilterBarController.m
macosx/FilterBarView.m
macosx/GlobalOptionsPopoverViewController.m
macosx/GroupToolbarItem.m
macosx/GroupsController.m
macosx/GroupsPrefsController.m
macosx/InfoActivityViewController.m
macosx/InfoFileViewController.m
macosx/InfoGeneralViewController.m
macosx/InfoOptionsViewController.m
macosx/InfoPeersViewController.m
macosx/InfoTabButtonBack.m
macosx/InfoTabButtonCell.m
macosx/InfoTrackersViewController.m
macosx/InfoWindowController.m
macosx/MessageWindowController.m
macosx/NSImageAdditions.m
macosx/NSMutableArrayAdditions.m
macosx/NSStringAdditions.m
macosx/PeerProgressIndicatorCell.m
macosx/PiecesView.h
macosx/PiecesView.m
macosx/PortChecker.h
macosx/PortChecker.m
macosx/PredicateEditorRowTemplateAny.h
macosx/PrefsController.m
macosx/PrefsWindow.h
macosx/ProgressGradients.m
macosx/StatsWindowController.m
macosx/StatusBarController.m
macosx/StatusBarView.m
macosx/Torrent.m
macosx/TorrentCell.m
macosx/TorrentGroup.m
macosx/TorrentTableView.m
macosx/TrackerCell.m
macosx/TrackerNode.h
macosx/TrackerNode.m
macosx/TrackerTableView.h
macosx/URLSheetWindow.xib
macosx/URLSheetWindowController.h
macosx/URLSheetWindowController.m

index 381eb17ac7b1c2040f728b5877f1a1d478fdba69..c52878e0f73c2332bc5826b2d4481ebd7415af5e 100644 (file)
                A29DF8BE0DB2545F00D04E5A /* verify.h in Headers */ = {isa = PBXBuildFile; fileRef = A2D22A110D65EED100007D5F /* verify.h */; };
                A29E653613F1603100048D71 /* evutil_rand.c in Sources */ = {isa = PBXBuildFile; fileRef = A29E653513F1603100048D71 /* evutil_rand.c */; };
                A2A1CB7A0BF29D5500AE959F /* PeerProgressIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A1CB780BF29D5500AE959F /* PeerProgressIndicatorCell.m */; };
-               A2A3065C0AAD24A80049E2AC /* UKFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306540AAD24A80049E2AC /* UKFileWatcher.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
-               A2A3065E0AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306560AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
-               A2A306600AAD24A80049E2AC /* UKKQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306580AAD24A80049E2AC /* UKKQueue.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
-               A2A306620AAD24A80049E2AC /* UKMainThreadProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A3065A0AAD24A80049E2AC /* UKMainThreadProxy.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+               A2A3065C0AAD24A80049E2AC /* UKFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306540AAD24A80049E2AC /* UKFileWatcher.m */; };
+               A2A3065E0AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306560AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m */; };
+               A2A306600AAD24A80049E2AC /* UKKQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306580AAD24A80049E2AC /* UKKQueue.m */; };
+               A2A306620AAD24A80049E2AC /* UKMainThreadProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A3065A0AAD24A80049E2AC /* UKMainThreadProxy.m */; };
                A2A4E9210DE0F7E9000CE197 /* web.h in Headers */ = {isa = PBXBuildFile; fileRef = A29EBE530DC01FC9006CEE80 /* web.h */; };
                A2A4E9220DE0F7EB000CE197 /* web.c in Sources */ = {isa = PBXBuildFile; fileRef = A29EBE520DC01FC9006CEE80 /* web.c */; };
                A2A4E9870DE10399000CE197 /* json.h in Headers */ = {isa = PBXBuildFile; fileRef = A2A4E9840DE1038C000CE197 /* json.h */; };
                                A2661D3B12D0E51B004F69D5 /* FilterBarView.m */,
                                A2ED7D8D0CEF431B00970975 /* FilterButton.h */,
                                A2ED7D8E0CEF431B00970975 /* FilterButton.m */,
-                               A28E1DDF0CFFD8EC00E16385 /* ButtonToolbarItem.h */,
                                A2C89D5F0CFCBF57004CC2BC /* ButtonToolbarItem.m */,
+                               A28E1DDF0CFFD8EC00E16385 /* ButtonToolbarItem.h */,
                                A21979890D07B78400438EA7 /* GroupToolbarItem.h */,
                                A219798A0D07B78400438EA7 /* GroupToolbarItem.m */,
                                A20BFFB50D091CC700CE5D2B /* ToolbarSegmentedCell.h */,
                0053D3D50C86774200545606 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CLANG_ENABLE_OBJC_ARC = YES;
                                FRAMEWORK_SEARCH_PATHS = macosx;
                                GCC_PREFIX_HEADER = macosx/Transmission_Prefix.pch;
                                INFOPLIST_FILE = macosx/Info.plist;
                4DF0C599089918A300DD8943 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CLANG_ENABLE_OBJC_ARC = YES;
                                FRAMEWORK_SEARCH_PATHS = macosx;
                                GCC_PREFIX_HEADER = macosx/Transmission_Prefix.pch;
                                INFOPLIST_FILE = macosx/Info.plist;
                A250CFEC0CDA19680068B4B6 /* Release - Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CLANG_ENABLE_OBJC_ARC = YES;
                                FRAMEWORK_SEARCH_PATHS = macosx;
                                GCC_PREFIX_HEADER = macosx/Transmission_Prefix.pch;
                                INFOPLIST_FILE = macosx/Info.plist;
index a7a31b3fdbb755e390fcdd34fa5a4a87538054aa..f16003bbc70b5e9771b19534ada41e9f8cfde248 100644 (file)
@@ -43,8 +43,8 @@ AboutWindowController * fAboutBoxInstance = nil;
     [fCopyrightField setStringValue: [[NSBundle mainBundle] localizedStringForKey: @"NSHumanReadableCopyright"
                                         value: nil table: @"InfoPlist"]];
     
-    [[fTextView textStorage] setAttributedString: [[NSAttributedString alloc] initWithPath:
-            [[NSBundle mainBundle] pathForResource: @"Credits" ofType: @"rtf"] documentAttributes: nil]];
+    [[fTextView textStorage] setAttributedString: [[[NSAttributedString alloc] initWithPath:
+            [[NSBundle mainBundle] pathForResource: @"Credits" ofType: @"rtf"] documentAttributes: nil] autorelease]];
     
     //size license button
     const CGFloat oldButtonWidth = NSWidth([fLicenseButton frame]);
@@ -65,6 +65,7 @@ AboutWindowController * fAboutBoxInstance = nil;
 
 - (void) windowWillClose: (id) sender
 {
+       [fAboutBoxInstance autorelease];
     fAboutBoxInstance = nil;
 }
 
index 6452cd5df5843320c80b1bbf65f98a6f196af487..eee77568a587ad412edffd02c1deb796183b25ba 100644 (file)
@@ -34,7 +34,7 @@
     IBOutlet NSButton * fStartCheck;
     IBOutlet NSPopUpButton * fGroupPopUp, * fPriorityPopUp;
     
-    __unsafe_unretained Controller * fController;
+    Controller * fController;
     
     Torrent * fTorrent;
     NSString * fDestination;
index 5d963ae8b585101f1d41a682d1d290bed89506ae..b55145c29d0cecba0f3a5ab0affee03d64029854 100644 (file)
@@ -53,7 +53,7 @@
     if ((self = [super initWithWindowNibName: @"AddMagnetWindow"]))
     {
         fTorrent = torrent;
-        fDestination = [path stringByExpandingTildeInPath];
+        fDestination = [[path stringByExpandingTildeInPath] retain];
         
         fController = controller;
         
 - (void) dealloc
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
+    
+    [fDestination release];
+    
+    [super dealloc];
 }
 
 - (Torrent *) torrent
     destination = [destination stringByExpandingTildeInPath];
     if (!fDestination || ![fDestination isEqualToString: destination])
     { 
-        fDestination = destination;
+        [fDestination release];
+        fDestination = [destination retain];
         
         [fTorrent changeDownloadFolderBeforeUsing: fDestination];
     }
     
     ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
     [fLocationImageView setImage: [iconTransformer transformedValue: fDestination]];
+    [iconTransformer release];
 }
 
 - (void) setGroupsMenu
     if ([[alert suppressionButton] state] == NSOnState)
         [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
     
+    [alert release];
     
     if (returnCode == NSAlertSecondButtonReturn)
         [self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
index 3f29c3d077f4360f8b1816b8ac305eebf3f179f2..4d8f02567f7965265311b8744fc4a3f4e9c8726f 100644 (file)
@@ -38,7 +38,7 @@
     
     IBOutlet FileOutlineController * fFileController;
     
-    __unsafe_unretained Controller * fController;
+    Controller * fController;
     
     Torrent * fTorrent;
     NSString * fDestination, * fTorrentFile;
index 85b8eff0891dfa06a9e1fc155529c289802814b8..11ef7a918e5b249a4df4b33e57d8c2b069efe1ad 100644 (file)
     if ((self = [super initWithWindowNibName: @"AddWindow"]))
     {
         fTorrent = torrent;
-        fDestination = [path stringByExpandingTildeInPath];
+        fDestination = [[path stringByExpandingTildeInPath] retain];
         fLockDestination = lockDestination;
         
         fController = controller;
         
-        fTorrentFile = [torrentFile stringByExpandingTildeInPath];
+        fTorrentFile = [[torrentFile stringByExpandingTildeInPath] retain];
         
         fDeleteTorrentInitial = deleteTorrent;
         fDeleteEnableInitial = canToggleDelete;
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
     [fTimer invalidate];
+    
+    [fDestination release];
+    [fTorrentFile release];
+    
+    [super dealloc];
 }
 
 - (Torrent *) torrent
     destination = [destination stringByExpandingTildeInPath];
     if (!fDestination || ![fDestination isEqualToString: destination])
     { 
-        fDestination = destination;
+        [fDestination release];
+        fDestination = [destination retain];
         
         [fTorrent changeDownloadFolderBeforeUsing: fDestination];
     }
     
     ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
     [fLocationImageView setImage: [iconTransformer transformedValue: fDestination]];
+    [iconTransformer release];
 }
 
 - (void) setGroupsMenu
     if ([[alert suppressionButton] state] == NSOnState)
         [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
     
+    [alert release];
     
     if (returnCode == NSAlertSecondButtonReturn)
         [self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
index 6233cb280f553228d66aae136b139e67aeb8bd41..368c8767ead1142a4ba7cab26c700daddffcab92 100644 (file)
     return self;
 }
 
+- (void) dealloc
+{
+    [fAttributes release];
+    [super dealloc];
+}
 
 - (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
 {
         [fAttributes setObject: [NSColor whiteColor] forKey: NSForegroundColorAttributeName];
         [fAttributes setObject: stringShadow forKey: NSShadowAttributeName];
         
+        [stringShadow release];
     }
     
     NSRect badgeRect;
index 509a6b3edc36df56a3d732e886aa9dcb32a56b92..b21d0c3d515531d78e0e98feb99aeab88d52ceb5 100644 (file)
@@ -37,6 +37,7 @@
         
         BadgeView * view = [[BadgeView alloc] initWithLib: lib];
         [[NSApp dockTile] setContentView: view];
+        [view release];
         
         fHashes = [[NSMutableSet alloc] init];
     }
 - (void) dealloc
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
+    
+    [fHashes release];
+    
+    [super dealloc];
 }
 
 - (void) updateBadgeWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
index dc60ec715b84b93a843464c4b02c5ff96c05a9c5..d49803ce3101e1d6f9cf09d2008c0b1075d59914 100644 (file)
@@ -37,7 +37,7 @@ typedef enum
 {
     NSURLDownload * fDownload;
     
-    __unsafe_unretained BlocklistDownloaderViewController * fViewController;
+    BlocklistDownloaderViewController * fViewController;
     
     NSString * fDestination;
     NSUInteger fCurrentSize;
index 7bb1d4f8c9f0e6ee42a52a4b3566232c2d77eb7f..3854784059fa98e2ab35ade44c9c758c5318861c 100644 (file)
 
 - (void) startDownload;
 - (void) decompressBlocklist;
+- (void) finishDownloadSuccess;
 
 @end
 
 @implementation BlocklistDownloader
 
-BlocklistDownloader * fBLDownloader = nil;
+BlocklistDownloader * fDownloader = nil;
 + (BlocklistDownloader *) downloader
 {
-    if (!fBLDownloader)
+    if (!fDownloader)
     {
-        fBLDownloader = [[BlocklistDownloader alloc] init];
-        [fBLDownloader startDownload];
+        fDownloader = [[BlocklistDownloader alloc] init];
+        [fDownloader startDownload];
     }
     
-    return fBLDownloader;
+    return fDownloader;
 }
 
 + (BOOL) isRunning
 {
-    return fBLDownloader != nil;
+    return fDownloader != nil;
 }
 
 - (void) setViewController: (BlocklistDownloaderViewController *) viewController
@@ -73,6 +74,12 @@ BlocklistDownloader * fBLDownloader = nil;
     }
 }
 
+- (void) dealloc
+{
+    [fDownload release];
+    [fDestination release];
+    [super dealloc];
+}
 
 - (void) cancelDownload
 {
@@ -82,7 +89,8 @@ BlocklistDownloader * fBLDownloader = nil;
     
     [[BlocklistScheduler scheduler] updateSchedule];
     
-    fBLDownloader = nil;
+    fDownloader = nil;
+    [self release];
 }
 
 //using the actual filename is the best bet
@@ -93,7 +101,8 @@ BlocklistDownloader * fBLDownloader = nil;
 
 - (void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
 {
-    fDestination = path;
+    [fDestination release];
+    fDestination = [path retain];
 }
 
 - (void) download: (NSURLDownload *) download didReceiveResponse: (NSURLResponse *) response
@@ -119,44 +128,14 @@ BlocklistDownloader * fBLDownloader = nil;
     [[NSUserDefaults standardUserDefaults] setObject: [NSDate date] forKey: @"BlocklistNewLastUpdate"];
     [[BlocklistScheduler scheduler] updateSchedule];
     
-    fBLDownloader = nil;
+    fDownloader = nil;
+    [self release];
 }
 
 - (void) downloadDidFinish: (NSURLDownload *) download
 {
     fState = BLOCKLIST_DL_PROCESSING;
-    
-    [fViewController setStatusProcessing];
-    
-    //process data
-    NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
-    
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        [self decompressBlocklist];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
-            
-            //delete downloaded file
-            [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
-            
-            if (count > 0)
-                [fViewController setFinished];
-            else
-                [fViewController setFailed: NSLocalizedString(@"The specified blocklist file did not contain any valid rules.",
-                                                              "blocklist fail message")];
-            
-            //update last updated date for schedule
-            NSDate * date = [NSDate date];
-            [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdate"];
-            [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdateSuccess"];
-            [[BlocklistScheduler scheduler] updateSchedule];
-            
-            [[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
-            
-            fBLDownloader = nil;
-        });
-    });
+    [self performSelectorInBackground: @selector(finishDownloadSuccess) withObject: nil];
 }
 
 - (BOOL) download: (NSURLDownload *) download shouldDecodeSourceDataOfMIMEType: (NSString *) encodingType
@@ -216,6 +195,7 @@ BlocklistDownloader * fBLDownloader = nil;
                {
                        success = NO;
                }
+               [unzip release];
                
                if (success) {
                        //Now find out what file we actually extracted; don't just assume it matches the zipfile's name
@@ -236,19 +216,57 @@ BlocklistDownloader * fBLDownloader = nil;
                                [zipinfo launch];
                                [zipinfo waitUntilExit];
                                
-                               NSString * actualFilename = [[NSString alloc] initWithData: [zipinfoOutput readDataToEndOfFile]
-                                                encoding: NSUTF8StringEncoding];
+                               NSString * actualFilename = [[[NSString alloc] initWithData: [zipinfoOutput readDataToEndOfFile]
+                                                encoding: NSUTF8StringEncoding] autorelease];
                                actualFilename = [actualFilename stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
                                NSString * newBlocklistPath = [workingDirectory stringByAppendingPathComponent: actualFilename];
                                
                                //Finally, delete the ZIP file; we're done with it, and we'll return the unzipped blocklist
                                [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
                 
-                fDestination = newBlocklistPath;
+                [fDestination release];
+                fDestination = [newBlocklistPath retain];
                        }
             @catch(id exc) {}
+                       [zipinfo release];
                }               
        }
 }
 
+
+- (void) finishDownloadSuccess
+{
+    @autoreleasepool
+    {
+        [fViewController setStatusProcessing];
+        
+        //process data
+        NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
+        
+        [self decompressBlocklist];
+        
+        const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
+        
+        //delete downloaded file
+        [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
+        
+        if (count > 0)
+            [fViewController setFinished];
+        else
+            [fViewController setFailed: NSLocalizedString(@"The specified blocklist file did not contain any valid rules.",
+                                            "blocklist fail message")];
+        
+        //update last updated date for schedule
+        NSDate * date = [NSDate date];
+        [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdate"];
+        [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdateSuccess"];
+        [[BlocklistScheduler scheduler] updateSchedule];
+        
+        [[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
+    }
+    
+    fDownloader = nil;
+    [self release];
+}
+
 @end
index 430399643c4465ea2507237b8edf588ff9ff99b0..84f2f06890e8d5be9be72c3e95d6d191d311cd37 100644 (file)
@@ -29,7 +29,7 @@
 
 @interface BlocklistDownloaderViewController : NSObject
 {    
-    __unsafe_unretained PrefsController * fPrefsController;
+    PrefsController * fPrefsController;
     
     IBOutlet NSWindow * fStatusWindow;
     IBOutlet NSProgressIndicator * fProgressBar;
index 72b406f2f1cf5380d511cb3b83590d9ff387c7a6..d3705198cd683cb5c9341608eaa328848ca436b9 100644 (file)
 
 @implementation BlocklistDownloaderViewController
 
-BlocklistDownloaderViewController * fBLViewController = nil;
 + (void) downloadWithPrefsController: (PrefsController *) prefsController
 {
-    if (!fBLViewController)
-    {
-        fBLViewController = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
-        [fBLViewController startDownload];
-    }
+    BlocklistDownloaderViewController * downloader = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
+    [downloader startDownload];
 }
 
 - (void) awakeFromNib
@@ -105,7 +101,7 @@ BlocklistDownloaderViewController * fBLViewController = nil;
     [NSApp endSheet: fStatusWindow];
     [fStatusWindow orderOut: self];
     
-    fBLViewController = nil;
+    [self release];
 }
 
 - (void) setFailed: (NSString *) error
@@ -113,7 +109,7 @@ BlocklistDownloaderViewController * fBLViewController = nil;
     [NSApp endSheet: fStatusWindow];
     [fStatusWindow orderOut: self];
     
-    NSAlert * alert = [[NSAlert alloc] init];
+    NSAlert * alert = [[[NSAlert alloc] init] autorelease];
     [alert addButtonWithTitle: NSLocalizedString(@"OK", "Blocklist -> button")];
     [alert setMessageText: NSLocalizedString(@"Download of the blocklist failed.", "Blocklist -> message")];
     [alert setAlertStyle: NSWarningAlertStyle];
@@ -152,8 +148,7 @@ BlocklistDownloaderViewController * fBLViewController = nil;
 - (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info
 {
     [[alert window] orderOut: self];
-    
-    fBLViewController = nil;
+    [self release];
 }
 
 @end
index 762a9d498a9edec142cd6ef37d39bee396f6cc8c..bece2ed41eb9717e08bad965aef9d4b9cded579f 100644 (file)
 BonjourController * fDefaultController = nil;
 + (BonjourController *) defaultController
 {
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
+    if (!fDefaultController)
         fDefaultController = [[BonjourController alloc] init];
-    });
-    
     return fDefaultController;
 }
 
+- (void) dealloc
+{
+    [fService release];
+    [super dealloc];
+}
 
 - (void) startWithPort: (NSInteger) port
 {
@@ -53,6 +55,7 @@ BonjourController * fDefaultController = nil;
 - (void) stop
 {
     [fService stop];
+    [fService release];
     fService = nil;
 }
 
index 581551a37470377eaf36541c9e365d9c4bbc1a11..414eeea63d0f4cab8ca0c374e0f91e46e2ae8696 100644 (file)
@@ -25,5 +25,7 @@
 #import <Cocoa/Cocoa.h>
 
 @interface ButtonToolbarItem : NSToolbarItem
+{
+}
 
 @end
index 6fa53d41b302189239c497b23eefce4cf5694468..803f7e6f67ad2f8f16fd5dac2620afc56614e00d 100644 (file)
@@ -37,7 +37,7 @@
     [menuItem setTarget: [self target]];
     [menuItem setEnabled: [[self target] validateToolbarItem: self]];
     
-    return menuItem;
+    return [menuItem autorelease];
 }
 
 @end
index 910985094b4106ce3a1f4109d319b60c7f2969f3..273bad03001cf9bbf6477dd0fdcb9fbf32987fb3 100644 (file)
@@ -106,9 +106,6 @@ typedef enum
     
     NSMutableSet                    * fAddingTransfers;
     
-    NSMutableSet                    * fAddWindows;
-    URLSheetWindowController        * fUrlSheetController;
-    
     BOOL                            fGlobalPopoverShown;
     BOOL                            fSoundPlaying;
 }
@@ -130,6 +127,7 @@ typedef enum
 
 - (void) openURL: (NSString *) urlString;
 - (void) openURLShowSheet: (id) sender;
+- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode;
 
 - (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
 
index 8e6bda73791db3e9b76130d7651599795766d4ee..f6924f8a93f725b6415f8ec398dc6c41c80035bb 100644 (file)
@@ -139,20 +139,20 @@ static void altSpeedToggledCallback(tr_session * handle UNUSED, bool active, boo
 {
     NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [[NSNumber alloc] initWithBool: active], @"Active",
                                 [[NSNumber alloc] initWithBool: byUser], @"ByUser", nil];
-    [(__bridge Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
+    [(Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
         withObject: dict waitUntilDone: NO];
 }
 
 static tr_rpc_callback_status rpcCallback(tr_session * handle UNUSED, tr_rpc_callback_type type, struct tr_torrent * torrentStruct,
                                             void * controller)
 {
-    [(__bridge Controller *)controller rpcCallback: type forTorrentStruct: torrentStruct];
+    [(Controller *)controller rpcCallback: type forTorrentStruct: torrentStruct];
     return TR_RPC_NOREMOVE; //we'll do the remove manually
 }
 
 static void sleepCallback(void * controller, io_service_t y, natural_t messageType, void * messageArgument)
 {
-    [(__bridge Controller *)controller sleepCallback: messageType argument: messageArgument];
+    [(Controller *)controller sleepCallback: messageType argument: messageArgument];
 }
 
 @implementation Controller
@@ -172,6 +172,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [alert setAlertStyle: NSCriticalAlertStyle];
         
         [alert runModal];
+        [alert release];
         
         //kill ourselves right away
         exit(0);
@@ -181,10 +182,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [[NSBundle mainBundle] pathForResource: @"Defaults" ofType: @"plist"]]];
     
     //set custom value transformers
-    ExpandedPathToPathTransformer * pathTransformer = [[ExpandedPathToPathTransformer alloc] init];
+    ExpandedPathToPathTransformer * pathTransformer = [[[ExpandedPathToPathTransformer alloc] init] autorelease];
     [NSValueTransformer setValueTransformer: pathTransformer forName: @"ExpandedPathToPathTransformer"];
     
-    ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
+    ExpandedPathToIconTransformer * iconTransformer = [[[ExpandedPathToIconTransformer alloc] init] autorelease];
     [NSValueTransformer setValueTransformer: iconTransformer forName: @"ExpandedPathToIconTransformer"];
     
     //cover our asses
@@ -202,6 +203,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         
         if ([alert runModal] == NSAlertSecondButtonReturn)
             exit(0);
+        [alert release];
         
         [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningLegal"];
     }
@@ -340,11 +342,11 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         fGlobalPopoverShown = NO;
         fSoundPlaying = NO;
         
-        tr_sessionSetAltSpeedFunc(fLib, altSpeedToggledCallback, (__bridge void *)(self));
+        tr_sessionSetAltSpeedFunc(fLib, altSpeedToggledCallback, self);
         if (usesSpeedLimitSched)
             [fDefaults setBool: tr_sessionUsesAltSpeed(fLib) forKey: @"SpeedLimit"];
         
-        tr_sessionSetRPCCallback(fLib, rpcCallback, (__bridge void *)(self));
+        tr_sessionSetRPCCallback(fLib, rpcCallback, self);
         
         [GrowlApplicationBridge setGrowlDelegate: self];
         
@@ -366,6 +368,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [toolbar setAutosavesConfiguration: YES];
     [toolbar setDisplayMode: NSToolbarDisplayModeIconOnly];
     [fWindow setToolbar: toolbar];
+    [toolbar release];
     
     [fWindow setDelegate: self]; //do manually to avoid placement issue
     
@@ -435,7 +438,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     //register for sleep notifications
     IONotificationPortRef notify;
     io_object_t iterator;
-    if ((fRootPort = IORegisterForSystemPower((__bridge void *)(self), & notify, sleepCallback, &iterator)))
+    if ((fRootPort = IORegisterForSystemPower(self, & notify, sleepCallback, &iterator)))
         CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notify), kCFRunLoopCommonModes);
     else
         NSLog(@"Could not IORegisterForSystemPower");
@@ -465,6 +468,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
                 if (!fPauseOnLaunch && (waitToStart = [historyItem objectForKey: @"WaitToStart"]) && [waitToStart boolValue])
                     [waitToStartTorrents addObject: torrent];
                 
+                [torrent release];
             }
         }
         
@@ -595,6 +599,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             if (allowNeverAgain)
                 [fDefaults setBool: ([[alert suppressionButton] state] != NSOnState) forKey: @"WarningDonate"];
             
+            [alert release];
         }
     }
 }
@@ -665,6 +670,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     {   
         if ([fAutoImportTimer isValid])
             [fAutoImportTimer invalidate];
+        [fAutoImportTimer release];
     }
     
     [fBadger setQuitting];
@@ -676,7 +682,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         {
             NSURLDownload * download = [downloadDict objectForKey: @"Download"];
             [download cancel];
+            [download release];
         }
+        [fPendingTorrentDownloads release];
     }
     
     //remember window states and close all windows
@@ -695,6 +703,26 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [self updateTorrentHistory];
     [fTableView saveCollapsedGroups];
     
+    //remaining calls the same as dealloc 
+    [fInfoController release];
+    [fMessageController release];
+    [fPrefsController release];
+    
+    [fStatusBar release];
+    [fFilterBar release];
+    
+    [fTorrents release];
+    [fDisplayedTorrents release];
+    
+    [fAddingTransfers release];
+    
+    [fOverlayWindow release];
+    [fBadger release];
+    
+    [fAutoImportedNames release];
+    
+    [fPreviewPanel release];
+    
     //complete cleanup
     tr_sessionClose(fLib);
 }
@@ -723,15 +751,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     {
         [download cancel];
         
-        [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
-        if ([fPendingTorrentDownloads count] == 0)
-            fPendingTorrentDownloads = nil;
-        
         NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"),
             [NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
             "Download not a torrent -> message"), suggestedName,
             [[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]],
             NSLocalizedString(@"OK", "Download not a torrent -> button"), nil, nil);
+        
+        [download release];
     }
     else
         [download setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]]
@@ -740,7 +766,11 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 -(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
 {
-    [(NSMutableDictionary *)[fPendingTorrentDownloads objectForKey: [[download request] URL]] setObject: path forKey: @"Path"];
+    if (!fPendingTorrentDownloads)
+        fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
+    
+    [fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
+                    path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
 }
 
 - (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error
@@ -753,7 +783,12 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     
     [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
     if ([fPendingTorrentDownloads count] == 0)
+    {
+        [fPendingTorrentDownloads release];
         fPendingTorrentDownloads = nil;
+    }
+    
+    [download release];
 }
 
 - (void) downloadDidFinish: (NSURLDownload *) download
@@ -767,7 +802,12 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     
     [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
     if ([fPendingTorrentDownloads count] == 0)
+    {
+        [fPendingTorrentDownloads release];
         fPendingTorrentDownloads = nil;
+    }
+    
+    [download release];
 }
 
 - (void) application: (NSApplication *) app openFiles: (NSArray *) filenames
@@ -861,10 +901,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
                                                     lockDestination: lockDestination controller: self torrentFile: torrentPath
                                                     deleteTorrent: deleteTorrentFile canToggleDelete: canToggleDelete];
             [addController showWindow: self];
-            
-            if (!fAddWindows)
-                fAddWindows = [NSMutableSet set];
-            [fAddWindows addObject: addController];
         }
         else
         {
@@ -873,6 +909,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             
             [torrent update];
             [fTorrents addObject: torrent];
+            [torrent release];
             
             if (!fAddingTransfers)
                 fAddingTransfers = [[NSMutableSet alloc] init];
@@ -886,6 +923,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 - (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add
 {
     Torrent * torrent = [addController torrent];
+    [addController autorelease];
     
     if (add)
     {
@@ -893,6 +931,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         
         [torrent update];
         [fTorrents addObject: torrent];
+        [torrent release];
         
         if (!fAddingTransfers)
             fAddingTransfers = [[NSMutableSet alloc] init];
@@ -903,11 +942,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     else
     {
         [torrent closeRemoveTorrent: NO];
+        [torrent release];
     }
-    
-    [fAddWindows removeObject: addController];
-    if ([fAddWindows count] == 0)
-        fAddWindows = nil;
 }
 
 - (void) openMagnet: (NSString *) address
@@ -945,10 +981,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         AddMagnetWindowController * addController = [[AddMagnetWindowController alloc] initWithTorrent: torrent destination: location
                                                         controller: self];
         [addController showWindow: self];
-        
-        if (!fAddWindows)
-            fAddWindows = [NSMutableSet set];
-        [fAddWindows addObject: addController];
     }
     else
     {
@@ -957,6 +989,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         
         [torrent update];
         [fTorrents addObject: torrent];
+        [torrent release];
         
         if (!fAddingTransfers)
             fAddingTransfers = [[NSMutableSet alloc] init];
@@ -969,6 +1002,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 - (void) askOpenMagnetConfirmed: (AddMagnetWindowController *) addController add: (BOOL) add
 {
     Torrent * torrent = [addController torrent];
+    [addController autorelease];
     
     if (add)
     {
@@ -976,6 +1010,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         
         [torrent update];
         [fTorrents addObject: torrent];
+        [torrent release];
         
         if (!fAddingTransfers)
             fAddingTransfers = [[NSMutableSet alloc] init];
@@ -986,22 +1021,23 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     else
     {
         [torrent closeRemoveTorrent: NO];
+        [torrent release];
     }
-    
-    [fAddWindows removeObject: addController];
-    if ([fAddWindows count] == 0)
-        fAddWindows = nil;
 }
 
 - (void) openCreatedFile: (NSNotification *) notification
 {
     NSDictionary * dict = [notification userInfo];
-    [self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] addType: ADD_CREATED forcePath: [dict objectForKey: @"Path"]];
+    [self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] addType: ADD_CREATED
+                        forcePath: [dict objectForKey: @"Path"]];
+    [dict release];
 }
 
 - (void) openFilesWithDict: (NSDictionary *) dictionary
 {
     [self openFiles: [dictionary objectForKey: @"Filenames"] addType: [[dictionary objectForKey: @"AddType"] intValue] forcePath: nil];
+    
+    [dictionary release];
 }
 
 //called on by applescript
@@ -1053,6 +1089,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [alert runModal];
     if ([[alert suppressionButton] state] == NSOnState)
         [fDefaults setBool: NO forKey: @"WarningInvalidOpen"];
+    [alert release];
 }
 
 - (void) invalidOpenMagnetAlert: (NSString *) address
@@ -1070,6 +1107,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [alert runModal];
     if ([[alert suppressionButton] state] == NSOnState)
         [fDefaults setBool: NO forKey: @"WarningInvalidOpen"];
+    [alert release];
 }
 
 - (void) duplicateOpenAlert: (NSString *) name
@@ -1090,6 +1128,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [alert runModal];
     if ([[alert suppressionButton] state])
         [fDefaults setBool: NO forKey: @"WarningDuplicate"];
+    [alert release];
 }
 
 - (void) duplicateOpenMagnetAlert: (NSString *) address transferName: (NSString *) name
@@ -1114,6 +1153,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [alert runModal];
     if ([[alert suppressionButton] state])
         [fDefaults setBool: NO forKey: @"WarningDuplicate"];
+    [alert release];
 }
 
 - (void) openURL: (NSString *) urlString
@@ -1140,41 +1180,21 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         
         NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]
                                     cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 60];
-        
-        if ([fPendingTorrentDownloads objectForKey: [request URL]])
-        {
-            NSLog(@"Already downloading %@", [request URL]);
-            return;
-        }
-        
-        NSURLDownload * download = [[NSURLDownload alloc] initWithRequest: request delegate: self];
-        
-        if (!fPendingTorrentDownloads)
-            fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
-        
-        [fPendingTorrentDownloads setObject: [NSMutableDictionary dictionaryWithObject: download forKey: @"Download"] forKey: [request URL]];
+        [[NSURLDownload alloc] initWithRequest: request delegate: self];
     }
 }
 
 - (void) openURLShowSheet: (id) sender
 {
-    if (!fUrlSheetController)
-    {
-        fUrlSheetController = [[URLSheetWindowController alloc] initWithController: self];
-        
-        [NSApp beginSheet: [fUrlSheetController window] modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(urlSheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
-    }
+    [[[URLSheetWindowController alloc] initWithController: self] beginSheetForWindow: fWindow];
 }
 
-- (void) urlSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
+- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
 {
     if (returnCode == 1)
-    {
-        NSString * urlString = [fUrlSheetController urlString];
         [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
-    }
     
-    fUrlSheetController = nil;
+    [controller release];
 }
 
 - (void) createFile: (id) sender
@@ -1256,6 +1276,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 - (void) removeTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
 {
+    [torrents retain];
 
     if ([fDefaults boolForKey: @"CheckRemove"])
     {
@@ -1318,7 +1339,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             
             NSBeginAlertSheet(title, NSLocalizedString(@"Remove", "Removal confirm panel -> button"),
                 NSLocalizedString(@"Cancel", "Removal confirm panel -> button"), nil, fWindow, self,
-                nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), (__bridge void *)dict, message);
+                nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), dict, message);
             return;
         }
     }
@@ -1331,6 +1352,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     NSArray * torrents = [dict objectForKey: @"Torrents"];
     if (returnCode == NSAlertDefaultReturn)
         [self confirmRemoveTorrents: torrents deleteData: [[dict objectForKey: @"DeleteData"] boolValue]];
+    else
+        [torrents release];
+    
+    [dict release];
 }
 
 - (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
@@ -1418,6 +1443,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [fTableView selectValues: selectedValues];
     
     [self fullUpdateUI];
+    
+    #warning why do we need them retained?
+    [torrents autorelease];
 }
 
 - (void) removeNoDelete: (id) sender
@@ -1459,7 +1487,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
                                      "Remove completed confirm panel -> message");
         }
         
-        NSAlert * alert = [[NSAlert alloc] init];
+        NSAlert * alert = [[[NSAlert alloc] init] autorelease];
         [alert setMessageText: message];
         [alert setInformativeText: info];
         [alert setAlertStyle: NSWarningAlertStyle];
@@ -1473,6 +1501,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         
         if (returnCode != NSAlertFirstButtonReturn)
         {
+            [torrents release];
             return;
         }
     }
@@ -1520,6 +1549,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 {
     if ([torrents count] == 0)
     {
+        [torrents release];
         return;
     }
     
@@ -1556,6 +1586,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             [alert setAlertStyle: NSWarningAlertStyle];
             
             [alert runModal];
+            [alert release];
         }
         
         [torrents removeObjectAtIndex: 0];
@@ -2269,7 +2300,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
                         TorrentGroup * newGroup = [groupsByIndex objectForKey: [NSNumber numberWithInteger: groupValue]];
                         if (!newGroup)
                         {
-                            newGroup = [[TorrentGroup alloc] initWithGroup: groupValue];
+                            newGroup = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
                             [groupsByIndex setObject: newGroup forKey: [NSNumber numberWithInteger: groupValue]];
                             [fDisplayedTorrents addObject: newGroup];
                             
@@ -2315,7 +2346,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             TorrentGroup * group = [groupsByIndex objectForKey: [NSNumber numberWithInteger: groupValue]];
             if (!group)
             {
-                group = [[TorrentGroup alloc] initWithGroup: groupValue];
+                group = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
                 [groupsByIndex setObject: group forKey: [NSNumber numberWithInteger: groupValue]];
                 [fDisplayedTorrents addObject: group];
                 
@@ -2378,7 +2409,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
                 TorrentGroup * group = [groupsByIndex objectForKey: [NSNumber numberWithInteger: groupValue]];
                 if (!group)
                 {
-                    group = [[TorrentGroup alloc] initWithGroup: groupValue];
+                    group = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
                     [groupsByIndex setObject: group forKey: [NSNumber numberWithInteger: groupValue]];
                 }
                 
@@ -2446,6 +2477,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     
     if (fAddingTransfers)
     {
+        [fAddingTransfers release];
         fAddingTransfers = nil;
     }
 }
@@ -2470,6 +2502,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         
         [popover showRelativeToRect: [sender frame] ofView: sender preferredEdge: NSMaxYEdge];
         
+        [viewController release];
+        [popover release];
     }
     else
     {
@@ -2505,9 +2539,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         const NSInteger groupMenuCount = [groupMenu numberOfItems];
         for (NSInteger i = 0; i < groupMenuCount; i++)
         {
-            NSMenuItem * item = [groupMenu itemAtIndex: 0];
+            NSMenuItem * item = [[groupMenu itemAtIndex: 0] retain];
             [groupMenu removeItemAtIndex: 0];
             [menu addItem: item];
+            [item release];
         }
     }
     else if (menu == fUploadMenu || menu == fDownloadMenu)
@@ -2526,6 +2561,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             [item setTarget: self];
             [item setRepresentedObject: [NSNumber numberWithInt: speedLimitActionValue[i]]];
             [menu addItem: item];
+            [item release];
         }
     }
     else if (menu == fRatioStopMenu)
@@ -2543,6 +2579,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             [item setTarget: self];
             [item setRepresentedObject: [NSNumber numberWithFloat: ratioLimitActionValue[i]]];
             [menu addItem: item];
+            [item release];
         }
     }
     else;
@@ -2589,6 +2626,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             description: NSLocalizedString(@"Bandwidth settings changed", "Growl notification description")
             notificationName: GROWL_AUTO_SPEED_LIMIT iconData: nil priority: 0 isSticky: NO clickContext: nil];
     
+    [dict release];
 }
 
 - (void) setLimitGlobalEnabled: (id) sender
@@ -2640,12 +2678,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         {
             if ([fAutoImportTimer isValid])
                 [fAutoImportTimer invalidate];
+            [fAutoImportTimer release];
             fAutoImportTimer = nil;
         }
         
         //check again in 10 seconds in case torrent file wasn't complete
-        fAutoImportTimer = [NSTimer scheduledTimerWithTimeInterval: 10.0 target: self 
-            selector: @selector(checkAutoImportDirectory) userInfo: nil repeats: NO];
+        fAutoImportTimer = [[NSTimer scheduledTimerWithTimeInterval: 10.0 target: self 
+            selector: @selector(checkAutoImportDirectory) userInfo: nil repeats: NO] retain];
         
         [self checkAutoImportDirectory];
     }
@@ -2657,10 +2696,15 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     {
         if ([fAutoImportTimer isValid])
             [fAutoImportTimer invalidate];
+        [fAutoImportTimer release];
         fAutoImportTimer = nil;
     }
     
-    fAutoImportedNames = nil;
+    if (fAutoImportedNames)
+    {
+        [fAutoImportedNames release];
+        fAutoImportedNames = nil;
+    }
     
     [self checkAutoImportDirectory];
 }
@@ -2721,6 +2765,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         tr_ctorFree(ctor);
     }
     
+    [newNames release];
 }
 
 - (void) beginCreateFile: (NSNotification *) notification
@@ -3258,6 +3303,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     if (!show)
     {
         [[fStatusBar view] removeFromSuperviewWithoutNeedingDisplay];
+        [fStatusBar release];
         fStatusBar = nil;
     }
     
@@ -3355,6 +3401,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     if (!show)
     {
         [[fFilterBar view] removeFromSuperviewWithoutNeedingDisplay];
+        [fFilterBar release];
         fFilterBar = nil;
     }
     
@@ -3383,13 +3430,14 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 - (void) beginPreviewPanelControl: (QLPreviewPanel *) panel
 {
-    fPreviewPanel = panel;
+    fPreviewPanel = [panel retain];
     [fPreviewPanel setDelegate: self];
     [fPreviewPanel setDataSource: self];
 }
 
 - (void) endPreviewPanelControl: (QLPreviewPanel *) panel
 {
+    [fPreviewPanel release];
     fPreviewPanel = nil;
 }
 
@@ -3466,12 +3514,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [button setStringValue: @""];
     
     [item setView: button];
+    [button release];
     
     const NSSize buttonSize = NSMakeSize(36.0, 25.0);
     [item setMinSize: buttonSize];
     [item setMaxSize: buttonSize];
     
-    return item;
+    return [item autorelease];
 }
 
 - (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident willBeInsertedIntoToolbar: (BOOL) flag
@@ -3551,7 +3600,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         GroupToolbarItem * groupItem = [[GroupToolbarItem alloc] initWithItemIdentifier: ident];
         
         NSSegmentedControl * segmentedControl = [[NSSegmentedControl alloc] initWithFrame: NSZeroRect];
-        [segmentedControl setCell: [[ToolbarSegmentedCell alloc] init]];
+        [segmentedControl setCell: [[[ToolbarSegmentedCell alloc] init] autorelease]];
         [groupItem setView: segmentedControl];
         NSSegmentedCell * segmentedCell = (NSSegmentedCell *)[segmentedControl cell];
         
@@ -3582,17 +3631,18 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause All", "All toolbar item -> label"),
                                         NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
         
+        [segmentedControl release];
         
         [groupItem setVisibilityPriority: NSToolbarItemVisibilityPriorityHigh];
         
-        return groupItem;
+        return [groupItem autorelease];
     }
     else if ([ident isEqualToString: TOOLBAR_PAUSE_RESUME_SELECTED])
     {
         GroupToolbarItem * groupItem = [[GroupToolbarItem alloc] initWithItemIdentifier: ident];
         
         NSSegmentedControl * segmentedControl = [[NSSegmentedControl alloc] initWithFrame: NSZeroRect];
-        [segmentedControl setCell: [[ToolbarSegmentedCell alloc] init]];
+        [segmentedControl setCell: [[[ToolbarSegmentedCell alloc] init] autorelease]];
         [groupItem setView: segmentedControl];
         NSSegmentedCell * segmentedCell = (NSSegmentedCell *)[segmentedControl cell];
         
@@ -3623,10 +3673,11 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause Selected", "Selected toolbar item -> label"),
                                         NSLocalizedString(@"Resume Selected", "Selected toolbar item -> label"), nil]];
         
+        [segmentedControl release];
         
         [groupItem setVisibilityPriority: NSToolbarItemVisibilityPriorityHigh];
         
-        return groupItem;
+        return [groupItem autorelease];
     }
     else if ([ident isEqualToString: TOOLBAR_FILTER])
     {
@@ -4224,7 +4275,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [menu addItem: [NSMenuItem separatorItem]];
     [menu addItemWithTitle: NSLocalizedString(@"Speed Limit", "Dock item") action: @selector(toggleSpeedLimit:) keyEquivalent: @""];
     
-    return menu;
+    return [menu autorelease];
 }
 
 - (NSRect) windowWillUseStandardFrame: (NSWindow *) window defaultFrame: (NSRect) defaultFrame
@@ -4387,6 +4438,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             for (torrent in fTorrents)
                 if (torrentStruct == [torrent torrentStruct])
                 {
+                    [torrent retain];
                     break;
                 }
             
@@ -4401,7 +4453,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         {
             case TR_RPC_TORRENT_ADDED:
                 [self performSelectorOnMainThread: @selector(rpcAddTorrentStruct:) withObject:
-                    [NSValue valueWithPointer: torrentStruct] waitUntilDone: NO];
+                    [[NSValue valueWithPointer: torrentStruct] retain] waitUntilDone: NO];
                 break;
             
             case TR_RPC_TORRENT_STARTED:
@@ -4440,6 +4492,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             
             default:
                 NSAssert1(NO, @"Unknown RPC command received: %d", type);
+                [torrent release];
         }
     }
 }
@@ -4447,6 +4500,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 - (void) rpcAddTorrentStruct: (NSValue *) torrentStructPtr
 {
     tr_torrent * torrentStruct = (tr_torrent *)[torrentStructPtr pointerValue];
+    [torrentStructPtr release];
     
     NSString * location = nil;
     if (tr_torrentGetDownloadDir(torrentStruct) != NULL)
@@ -4463,6 +4517,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     
     [torrent update];
     [fTorrents addObject: torrent];
+    [torrent release];
     
     if (!fAddingTransfers)
         fAddingTransfers = [[NSMutableSet alloc] init];
@@ -4473,17 +4528,20 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 - (void) rpcRemoveTorrent: (Torrent *) torrent
 {
-    [self confirmRemoveTorrents: [NSArray arrayWithObject: torrent] deleteData: NO];
+    [self confirmRemoveTorrents: [[NSArray arrayWithObject: torrent] retain] deleteData: NO];
+    [torrent release];
 }
 
 - (void) rpcRemoveTorrentDeleteData: (Torrent *) torrent
 {
-    [self confirmRemoveTorrents: [NSArray arrayWithObject: torrent] deleteData: YES];
+    [self confirmRemoveTorrents: [[NSArray arrayWithObject: torrent] retain] deleteData: YES];
+    [torrent release];
 }
 
 - (void) rpcStartedStoppedTorrent: (Torrent *) torrent
 {
     [torrent update];
+    [torrent release];
     
     [self updateUI];
     [self applyFilter];
@@ -4500,6 +4558,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [fInfoController updateOptions];
     }
     
+    [torrent release];
 }
 
 - (void) rpcMovedTorrent: (Torrent *) torrent
@@ -4510,6 +4569,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     if ([[fTableView selectedTorrents] containsObject: torrent])
         [fInfoController updateInfoStats];
     
+    [torrent release];
 }
 
 - (void) rpcUpdateQueue
index 8ca900554ac238ae4e21cc840a0b4c0f80035535..8efc03082331c0f6174f555b84528aabe614d56e 100644 (file)
@@ -67,7 +67,7 @@
     {
         fStarted = NO;
         
-        fPath = path;
+        fPath = [path retain];
         fInfo = tr_metaInfoBuilderCreate([fPath UTF8String]);
         
         if (fInfo->fileCount == 0)
@@ -81,7 +81,9 @@
             [alert setAlertStyle: NSWarningAlertStyle];
             
             [alert runModal];
+            [alert release];
             
+            [self release];
             return nil;
         }
         if (fInfo->totalSize == 0)
@@ -95,7 +97,9 @@
             [alert setAlertStyle: NSWarningAlertStyle];
             
             [alert runModal];
+            [alert release];
             
+            [self release];
             return nil;
         }
         
         [fPiecesField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d pieces, %@ each", "Create torrent -> info"),
                                                             fInfo->pieceCount, [NSString stringForFileSize: fInfo->pieceSize]]];
     
-    fLocation = [[[fDefaults stringForKey: @"CreatorLocation"] stringByExpandingTildeInPath] stringByAppendingPathComponent:
-                    [name stringByAppendingPathExtension: @"torrent"]];
+    fLocation = [[[[fDefaults stringForKey: @"CreatorLocation"] stringByExpandingTildeInPath] stringByAppendingPathComponent:
+                    [name stringByAppendingPathExtension: @"torrent"]] retain];
     [fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]];
     [fLocationField setToolTip: fLocation];
     
 
 - (void) dealloc
 {
+    [fPath release];
+    [fLocation release];
     
+    [fTrackers release];
     
     if (fInfo)
         tr_metaInfoBuilderFree(fInfo);
     
     [fTimer invalidate];
     
+    [super dealloc];
 }
 
 - (void) setLocation: (id) sender
     [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
         if (result == NSFileHandlingPanelOKButton)
         {
-            fLocation = [[panel URL] path];
+            [fLocation release];
+            fLocation = [[[panel URL] path] retain];
             
             [fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]];
             [fLocationField setToolTip: fLocation];
     [[self window] close];
 }
 
+- (void) windowWillClose: (NSNotification *) notification
+{
+    [self autorelease];
+}
+
 - (void) cancelCreateProgress: (id) sender
 {
     fInfo->abortFlag = 1;
     
     BOOL added = NO;
     
-    for (__strong NSString * tracker in tempTrackers)
+    for (NSString * tracker in tempTrackers)
     {
         tracker = [tracker stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
         
             [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorPrivateBlankAddress"];
     }
     
+    [alert release];
     
     if (returnCode == NSAlertFirstButtonReturn)
         [self performSelectorOnMainThread: @selector(createReal) withObject: nil waitUntilDone: NO];
     //check if the location currently exists
     if (![[NSFileManager defaultManager] fileExistsAtPath: [fLocation stringByDeletingLastPathComponent]])
     {
-        NSAlert * alert = [[NSAlert alloc] init];
+        NSAlert * alert = [[[NSAlert alloc] init] autorelease];
         [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> directory doesn't exist warning -> button")];
         [alert setMessageText: NSLocalizedString(@"The chosen torrent file location does not exist.",
                                                 "Create torrent -> directory doesn't exist warning -> title")];
         NSArray * pathComponents = [fLocation pathComponents];
         NSInteger count = [pathComponents count];
         
-        NSAlert * alert = [[NSAlert alloc] init];
+        NSAlert * alert = [[[NSAlert alloc] init] autorelease];
         [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> file already exists warning -> button")];
         [alert setMessageText: NSLocalizedString(@"A torrent file with this name and directory cannot be created.",
                                                 "Create torrent -> file already exists warning -> title")];
                 break;
             
             default:
-                alert = [[NSAlert alloc] init];
+                alert = [[[NSAlert alloc] init] autorelease];
                 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> failed -> button")];
                 [alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Creation of \"%@\" failed.",
                                                 "Create torrent -> failed -> title"), [fLocation lastPathComponent]]];
index 8f8dbc82bca42792685585c09af8ef63e23d59ef..85ff86472a9d73d1fb7651f4a6727183629963d8 100644 (file)
                                 smallFont, NSFontAttributeName, stringShadow, NSShadowAttributeName,
                                 paragraphStyle, NSParagraphStyleAttributeName, nil];
         
+        [stringShadow release];
+        [paragraphStyle release];
     }
     return self;
 }
 
+- (void) dealloc
+{
+    [fBadge release];
+    
+    [fMainLineAttributes release];
+    [fSubLineAttributes release];
+    
+    [super dealloc];
+}
 
 - (void) setOverlay: (NSImage *) icon mainLine: (NSString *) mainLine subLine: (NSString *) subLine
 {
+    [fBadge release];
     
     //create badge
     const NSRect badgeRect = NSMakeRect(0.0, 0.0, 325.0, 84.0);
index fca02c4e3a8b4e635a152ab5bcff73c468146bb3..86e5b062b16082765097bf19d60c34c3ef1d0379 100644 (file)
@@ -48,6 +48,7 @@
         
         DragOverlayView * view = [[DragOverlayView alloc] initWithFrame: [self frame]];
         [self setContentView: view];
+        [view release];
         
         [self setReleasedWhenClosed: NO];
         [self setIgnoresMouseEvents: YES];
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
+    [fFadeInAnimation release];
+    [fFadeOutAnimation release];
     
+    [super dealloc];
 }
 
 - (void) setTorrents: (NSArray *) files
index 37d63ee90171e446f087328f836fd23fac5d5891..456310fd5f46f89105fcab9ae61071a0fb282d99 100644 (file)
@@ -25,5 +25,7 @@
 #import <Foundation/Foundation.h>
 
 @interface ExpandedPathToIconTransformer : NSValueTransformer
+{
+}
 
 @end
\ No newline at end of file
index 14f289fb5873518d2d5f974c4e133f42008a1016..dd6c3f512cdd1cc785118b4f5258c5ede8c61776 100644 (file)
@@ -25,5 +25,7 @@
 #import <Foundation/Foundation.h>
 
 @interface ExpandedPathToPathTransformer : NSValueTransformer
+{
+}
 
 @end
\ No newline at end of file
index a6b326dfb0f55252b4401e935af733a9c21a4660..518c2f622b91d5d144e3fdd7e1fa1d19706ec2c4 100644 (file)
@@ -34,7 +34,7 @@
     
     NSString * fName;
     NSString * fPath;
-    Torrent * __unsafe_unretained fTorrent;
+    Torrent * fTorrent;
     uint64_t fSize;
     NSImage * fIcon;
     BOOL fIsFolder;
@@ -43,7 +43,7 @@
 @property (nonatomic, readonly) NSString * name;
 @property (nonatomic, readonly) NSString * path;
 
-@property (nonatomic, readonly, unsafe_unretained) Torrent * torrent;
+@property (nonatomic, readonly) Torrent * torrent;
 
 @property (nonatomic, readonly) uint64_t size;
 @property (nonatomic, readonly) NSImage * icon;
index 38da89270d93bc247c332e7880891961b74e9142..d8e99fae724f4adee22759e94dca852b303bdcde 100644 (file)
 - (id) copyWithZone: (NSZone *) zone
 {
     //this object is essentially immutable after initial setup
-    return self;
+    return [self retain];
 }
 
+- (void) dealloc
+{
+    [fName release];
+    [fPath release];
+    [fIndexes release];
+    
+    [fIcon release];
+    
+    [fChildren release];
+    
+    [super dealloc];
+}
 
 - (NSString *) description
 {
 - (NSImage *) icon
 {
     if (!fIcon)
-        fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fIsFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
-                                                                            : [fName pathExtension]];
+        fIcon = [[[NSWorkspace sharedWorkspace] iconForFileType: fIsFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
+                                                                            : [fName pathExtension]] retain];
     return fIcon;
 }
 
     if ((self = [super init]))
     {
         fIsFolder = isFolder;
-        fName = name;
-        fPath = path;
+        fName = [name retain];
+        fPath = [path retain];
         
         fIndexes = [[NSMutableIndexSet alloc] init];
         
index 6dd0537e53e51aa79a11aa0930854187cb68b775..253c7d8aed4bfd57f3367663791ada3e31a2effc 100644 (file)
                                 [NSFont messageFontOfSize: 9.0], NSFontAttributeName,
                                 statusParagraphStyle, NSParagraphStyleAttributeName,  nil];
         
+        [paragraphStyle release];
+        [statusParagraphStyle release];
     }
     return self;
 }
 
+- (void) dealloc
+{
+    [fTitleAttributes release];
+    [fStatusAttributes release];
+    
+    [super dealloc];
+}
+
+- (id) copyWithZone: (NSZone *) zone
+{
+    FileNameCell * copy = [super copyWithZone: zone];
+    
+    copy->fTitleAttributes = [fTitleAttributes retain];
+    copy->fStatusAttributes = [fStatusAttributes retain];
+    
+    return copy;
+}
+
 - (NSImage *) image
 {
     FileListNode * node = (FileListNode *)[self objectValue];
 - (NSAttributedString *) attributedTitle
 {
     NSString * title = [(FileListNode *)[self objectValue] name];
-    return [[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes];
+    return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease];
 }
 
 - (NSAttributedString *) attributedStatus
     NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@",
                             "Inspector -> Files tab -> file status string"), percentString, [NSString stringForFileSize: [node size]]];
     
-    return [[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes];
+    return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease];
 }
 
 @end
index cf259d2cdd1c1874856f29b6b8616632668da502..0c24fd28808fd081bad08ac497378c4300661f13 100644 (file)
@@ -29,7 +29,7 @@
 
 @interface FileOutlineController : NSObject
 {
-    __unsafe_unretained Torrent * fTorrent;
+    Torrent * fTorrent;
     NSMutableArray * fFileList;
     
     IBOutlet FileOutlineView * fOutline;
index 9f6943f506ebb06a99a68d0354c2671e19584fd6..6d074b9131459e162bba54a5c590b1378f873aa0 100644 (file)
@@ -73,6 +73,14 @@ typedef enum
     [self setTorrent: nil];
 }
 
+- (void) dealloc
+{
+    [fFileList release];
+    [fFilterText release];
+    
+    [super dealloc];
+}
+
 - (FileOutlineView *) outlineView
 {
     return fOutline;
@@ -84,6 +92,7 @@ typedef enum
     
     [fFileList setArray: [fTorrent fileList]];
     
+    [fFilterText release];
     fFilterText = nil;
     
     [fOutline reloadData];
@@ -198,7 +207,8 @@ typedef enum
     else
         [fOutline reloadData];
     
-    fFilterText = text;
+    [fFilterText release];
+    fFilterText = [text retain];
 }
 
 - (void) refresh
@@ -511,18 +521,21 @@ typedef enum
     [item setTarget: self];
     [item setTag: FILE_CHECK_TAG];
     [menu addItem: item];
+    [item release];
     
     item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Uncheck Selected", "File Outline -> Menu")
             action: @selector(setCheck:) keyEquivalent: @""];
     [item setTarget: self];
     [item setTag: FILE_UNCHECK_TAG];
     [menu addItem: item];
+    [item release];
     
     //only check selected
     item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Only Check Selected", "File Outline -> Menu")
             action: @selector(setOnlySelectedCheck:) keyEquivalent: @""];
     [item setTarget: self];
     [menu addItem: item];
+    [item release];
     
     [menu addItem: [NSMenuItem separatorItem]];
     
@@ -531,6 +544,7 @@ typedef enum
     NSMenu * priorityMenu = [[NSMenu alloc] initWithTitle: @"File Priority Menu"];
     [item setSubmenu: priorityMenu];
     [menu addItem: item];
+    [item release];
     
     item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"High", "File Outline -> Priority Menu")
             action: @selector(setPriority:) keyEquivalent: @""];
@@ -538,6 +552,7 @@ typedef enum
     [item setTag: FILE_PRIORITY_HIGH_TAG];
     [item setImage: [NSImage imageNamed: @"PriorityHighTemplate.png"]];
     [priorityMenu addItem: item];
+    [item release];
     
     item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Normal", "File Outline -> Priority Menu")
             action: @selector(setPriority:) keyEquivalent: @""];
@@ -545,6 +560,7 @@ typedef enum
     [item setTag: FILE_PRIORITY_NORMAL_TAG];
     [item setImage: [NSImage imageNamed: @"PriorityNormalTemplate.png"]];
     [priorityMenu addItem: item];
+    [item release];
     
     item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Low", "File Outline -> Priority Menu")
             action: @selector(setPriority:) keyEquivalent: @""];
@@ -552,7 +568,9 @@ typedef enum
     [item setTag: FILE_PRIORITY_LOW_TAG];
     [item setImage: [NSImage imageNamed: @"PriorityLowTemplate.png"]];
     [priorityMenu addItem: item];
+    [item release];
     
+    [priorityMenu release];
     
     [menu addItem: [NSMenuItem separatorItem]];
     
@@ -561,8 +579,9 @@ typedef enum
             action: @selector(revealFile:) keyEquivalent: @""];
     [item setTarget: self];
     [menu addItem: item];
+    [item release];
     
-    return menu;
+    return [menu autorelease];
 }
 
 - (NSUInteger) findFileNode: (FileListNode *) node inList: (NSArray *) list atIndexes: (NSIndexSet *) indexes currentParent: (FileListNode *) currentParent finalParent: (FileListNode **) parent
index ff0bff130950001ceed170c4ed65d0f65568a95a..8fd84548a82f37e8a3211cf67632670237991591 100644 (file)
 {
     FileNameCell * nameCell = [[FileNameCell alloc] init];
     [[self tableColumnWithIdentifier: @"Name"] setDataCell: nameCell];
+    [nameCell release];
     
     FilePriorityCell * priorityCell = [[FilePriorityCell alloc] init];
     [[self tableColumnWithIdentifier: @"Priority"] setDataCell: priorityCell];
+    [priorityCell release];
     
     [self setAutoresizesOutlineColumn: NO];
     [self setIndentationPerLevel: 14.0];
     fMouseRow = -1;
 }
 
+- (void) dealloc
+{
+    [super dealloc];
+}
 
 - (void) mouseDown: (NSEvent *) event
 {
index df00a51528208c5cf34070709c28e396708766da..eb26f61a0174609fc49cd6a148fea0c9158de426 100644 (file)
     
     NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: cellFrame options: options owner: controlView userInfo: userInfo];
     [controlView addTrackingArea: area];
+    [area release];
 }
 
 - (void) setHovered: (BOOL) hovered
index 0e3cfde745d261621cd81475c6822057dc3508d9..5fe59812ef57da4c1ccf3126fbab7d22dfd164de 100644 (file)
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
+    [super dealloc];
 }
 
 - (void) setFilter: (id) sender
         const NSInteger groupMenuCount = [groupMenu numberOfItems];
         for (NSInteger i = 0; i < groupMenuCount; i++)
         {
-            NSMenuItem * item = [groupMenu itemAtIndex: 0];
+            NSMenuItem * item = [[groupMenu itemAtIndex: 0] retain];
             [groupMenu removeItemAtIndex: 0];
             [menu addItem: item];
+            [item release];
         }
     }
 }
index 5c8b66e3f704d7b93ac0c1e35367354c2dec910f..e77774c5dead2abb710f29183ba9b3b699cf2785 100644 (file)
     return self;
 }
 
+- (void) dealloc
+{
+    [fGradient release];
+    [super dealloc];
+}
 
 - (BOOL) mouseDownCanMoveWindow
 {
index 435e6392fdb3f2b8307f0c0ab0c335ac81bfffad..d91cd50a1d34a0d5560758abd75a18bd31cc0022 100644 (file)
 
 - (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
 {
-    fInitialString = [control stringValue];
+    [fInitialString release];
+    fInitialString = [[control stringValue] retain];
     
     return YES;
 }
     if (fInitialString)
     {
         [control setStringValue: fInitialString];
+        [fInitialString release];
         fInitialString = nil;
     }
     return NO;
index d68180dd01b712fc4a96d7f3c60c6d0fbf356a11..466008d7b3975687d8bc679ed13b4da0abe0b6b7 100644 (file)
 
 @implementation GroupToolbarItem
 
+- (void) dealloc
+{
+    [fIdentifiers release];
+    [super dealloc];
+}
 
 - (void) setIdentifiers: (NSArray *) identifiers
 {
-    fIdentifiers = identifiers;
+    [fIdentifiers release];
+    fIdentifiers = [identifiers retain];
 }
 
 - (void) validate
@@ -38,7 +44,7 @@
     
     for (NSInteger i = 0; i < [control segmentCount]; i++)
         [control setEnabled: [[self target] validateToolbarItem:
-            [[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]]] forSegment: i];
+            [[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]] forSegment: i];
 }
 
 - (void) createMenu: (NSArray *) labels
         [addItem setTag: i];
         
         [menu addItem: addItem];
+        [addItem release];
     }
     
+    [menu release];
     [self setMenuFormRepresentation: menuItem];
+    [menuItem release];
 }
 
 - (NSMenuItem *) menuFormRepresentation
@@ -69,7 +78,7 @@
     const NSInteger count = [(NSSegmentedControl *)[self view] segmentCount];
     for (NSInteger i = 0; i < count; i++)
         [[[menuItem submenu] itemAtIndex: i] setEnabled: [[self target] validateToolbarItem:
-            [[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]]]];
+            [[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]]];
     
     return menuItem;
 }
index 55ec97693ecef421e9033f325afe77c404764702..cea76613db05197a32865edf2c80afd000268ca6 100644 (file)
@@ -54,10 +54,10 @@ GroupsController * fGroupsInstance = nil;
     {
         NSData * data;
         if ((data = [[NSUserDefaults standardUserDefaults] dataForKey: @"GroupDicts"]))
-            fGroups = [NSKeyedUnarchiver unarchiveObjectWithData: data];
+            fGroups = [[NSKeyedUnarchiver unarchiveObjectWithData: data] retain];
         else if ((data = [[NSUserDefaults standardUserDefaults] dataForKey: @"Groups"])) //handle old groups
         {
-            fGroups = [NSUnarchiver unarchiveObjectWithData: data];
+            fGroups = [[NSUnarchiver unarchiveObjectWithData: data] retain];
             [[NSUserDefaults standardUserDefaults] removeObjectForKey: @"Groups"];
             [self saveGroups];
         }
@@ -107,6 +107,11 @@ GroupsController * fGroupsInstance = nil;
     return self;
 }
 
+- (void) dealloc
+{
+    [fGroups release];
+    [super dealloc];
+}
 
 - (NSInteger) numberOfGroups
 {
@@ -299,11 +304,13 @@ GroupsController * fGroupsInstance = nil;
         [icon setSize: NSMakeSize(ICON_WIDTH_SMALL, ICON_WIDTH_SMALL)];
         
         [item setImage: icon];
+        [icon release];
     }
     else
         [item setImage: icon];
     
     [menu addItem: item];
+    [item release];
     
     for (NSMutableDictionary * dict in fGroups)
     {
@@ -319,14 +326,16 @@ GroupsController * fGroupsInstance = nil;
             [icon setSize: NSMakeSize(ICON_WIDTH_SMALL, ICON_WIDTH_SMALL)];
             
             [item setImage: icon];
+            [icon release];
         }
         else
             [item setImage: icon];
         
         [menu addItem: item];
+        [item release];
     }
     
-    return menu;
+    return [menu autorelease];
 }
 
 - (NSInteger) groupIndexForTorrent: (Torrent *) torrent;
@@ -353,6 +362,7 @@ GroupsController * fGroupsInstance = nil;
         NSMutableDictionary * tempDict = [dict mutableCopy];
         [tempDict removeObjectForKey: @"Icon"];
         [groups addObject: tempDict];
+        [tempDict release];
     }
     
     [[NSUserDefaults standardUserDefaults] setObject: [NSKeyedArchiver archivedDataWithRootObject: groups] forKey: @"GroupDicts"];
@@ -377,16 +387,19 @@ GroupsController * fGroupsInstance = nil;
     NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: [color blendedColorWithFraction: 0.45 ofColor:
                                 [NSColor whiteColor]] endingColor: color];
     [gradient drawInBezierPath: bp angle: 270.0];
+    [gradient release];
     
     //inside
     bp = [NSBezierPath bezierPathWithRoundedRect: NSInsetRect(rect, 1.0, 1.0) xRadius: 3.0 yRadius: 3.0];
     gradient = [[NSGradient alloc] initWithStartingColor: [color blendedColorWithFraction: 0.75 ofColor: [NSColor whiteColor]]
                 endingColor: [color blendedColorWithFraction: 0.2 ofColor: [NSColor whiteColor]]];
     [gradient drawInBezierPath: bp angle: 270.0];
+    [gradient release];
     
     [icon unlockFocus];
     
     [dict setObject: icon forKey: @"Icon"];
+    [icon release];
     
     return icon;
 }
index 6f4fc2f7323d6db8093f39a7837ca57ef7963d06..553d876d946c9c7ce35ccd2576fa324dbba94c50 100644 (file)
     NSString * location = [[GroupsController groups] customDownloadLocationForIndex: index];
     if (location)
     {
-        ExpandedPathToPathTransformer * pathTransformer = [[ExpandedPathToPathTransformer alloc] init];
+        ExpandedPathToPathTransformer * pathTransformer = [[[ExpandedPathToPathTransformer alloc] init] autorelease];
         [[fCustomLocationPopUp itemAtIndex: 0] setTitle: [pathTransformer transformedValue: location]];
-        ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
+        ExpandedPathToIconTransformer * iconTransformer = [[[ExpandedPathToIconTransformer alloc] init] autorelease];
         [[fCustomLocationPopUp itemAtIndex: 0] setImage: [iconTransformer transformedValue: location]];
     }
     else
index f27f754ec8e3549f592d7d45ab5299a1f75c1473..2f17aea54e8110a5076b373aefdfbab82209da49 100644 (file)
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
+    [fTorrents release];
     
+    [super dealloc];
 }
 
 - (void) setInfoForTorrents: (NSArray *) torrents
 {
     //don't check if it's the same in case the metadata changed
-    fTorrents = torrents;
+    [fTorrents release];
+    fTorrents = [torrents retain];
     
     fSet = NO;
 }
index 57d27204ffebd74ac2295dc398d84c8beb55d9a7..94df61dc2282e4f7e06dff64c25c904f3621bd59 100644 (file)
     [[fFileFilterField cell] setPlaceholderString: NSLocalizedString(@"Filter", "inspector -> file filter")];
 }
 
+- (void) dealloc
+{
+    [fTorrents release];
+    
+    [super dealloc];
+}
 
 - (void) setInfoForTorrents: (NSArray *) torrents
 {
     //don't check if it's the same in case the metadata changed
-    fTorrents = torrents;
+    [fTorrents release];
+    fTorrents = [torrents retain];
     
     fSet = NO;
 }
index e71095a382ba33abb86e2e235b25ed44b163d91d..8dee2fe734f4992c43bb18fcd0415a2c2675352d 100644 (file)
     return self;
 }
 
+- (void) dealloc
+{
+    [fTorrents release];
+    
+    [super dealloc];
+}
 
 - (void) setInfoForTorrents: (NSArray *) torrents
 {
     //don't check if it's the same in case the metadata changed
-    fTorrents = torrents;
+    [fTorrents release];
+    fTorrents = [torrents retain];
     
     fSet = NO;
 }
index 7ae151e6cd275c3c3accc9e7b3897e461809ad77..f8ec8bd3f625e0e3cc686f4886b362eec62dfd19 100644 (file)
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
+    [fTorrents release];
     
+    [super dealloc];
 }
 
 - (void) setInfoForTorrents: (NSArray *) torrents
 {
     //don't check if it's the same in case the metadata changed
-    fTorrents = torrents;
+    [fTorrents release];
+    fTorrents = [torrents retain];
     
     fSet = NO;
 }
 
 - (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
 {
-    fInitialString = [control stringValue];
+    [fInitialString release];
+    fInitialString = [[control stringValue] retain];
     
     return YES;
 }
     if (fInitialString)
     {
         [control setStringValue: fInitialString];
+        [fInitialString release];
         fInitialString = nil;
     }
     return NO;
index a85fc9d7cba9a1b6df351d622a9e6b1a4800fd40..e628326be82e9d19b9f3be37e37ab41798cb1463 100644 (file)
     [self setWebSeedTableHidden: YES animate: NO];
 }
 
+- (void) dealloc
+{
+    [fTorrents release];
+    
+    [fPeers release];
+    [fWebSeeds release];
+    
+    [fWebSeedTableAnimation release];
+    
+    [super dealloc];
+}
 
 #warning subclass?
 - (void) setInfoForTorrents: (NSArray *) torrents
 {
     //don't check if it's the same in case the metadata changed
-    fTorrents = torrents;
+    [fTorrents release];
+    fTorrents = [torrents retain];
     
     fSet = NO;
 }
     if (fWebSeedTableAnimation)
         [self setWebSeedTableHidden: !fWebSeeds animate: NO];
     
+    [fPeers release];
     fPeers = nil;
+    [fWebSeeds release];
     fWebSeeds = nil;
 }
 
 {
     if (animation == fWebSeedTableAnimation)
     {
+        [fWebSeedTableAnimation release];
         fWebSeedTableAnimation = nil;
     }
 }
     if (fWebSeedTableAnimation)
     {
         [fWebSeedTableAnimation stopAnimation]; // jumps to end frame
+        [fWebSeedTableAnimation release];
         fWebSeedTableAnimation = nil;
     }
 }
     
     if ([fTorrents count] == 0)
     {
+        [fPeers release];
         fPeers = nil;
         [fPeerTable reloadData];
         
     
     if (!hasWebSeeds)
     {
+        [fWebSeeds release];
         fWebSeeds = nil;
         [fWebSeedTable reloadData];
     }
     if (fWebSeedTableAnimation)
     {
         [fWebSeedTableAnimation stopAnimation];
+        [fWebSeedTableAnimation release];
         fWebSeedTableAnimation = nil;
     }
     
index 0b4dfa24a1b406bce04f770602fc3c6d3e4b2bd0..0954e0f9df40538c41cec7877217b1d1bdf62354 100644 (file)
     return self;
 }
 
+- (void) dealloc
+{
+    [fGradient release];
+    [super dealloc];
+}
 
 - (void) drawRect: (NSRect) rect
 {
index 08eecb75ee54768034127b7f7bd579115137d52e..4b9c7cf4d60577afb5e48969b9ce2121d42dd7be 100644 (file)
@@ -37,7 +37,7 @@
     fSelected = NO;
     
     //expects the icon to currently be set as the image
-    fIcon = [self image];
+    fIcon = [[self image] retain];
     [self setSelectedTab: fSelected];
 }
 
@@ -45,6 +45,8 @@
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
+    [fIcon release];
+    [super dealloc];
 }
 
 - (void) setSelectedTab: (BOOL) selected
@@ -83,6 +85,7 @@
     tabRect = NSMakeRect(0.0, 1.0, NSWidth(tabRect) - 1.0, NSHeight(tabRect) - 2.0);
     
     [gradient drawInRect: tabRect angle: 270.0];
+    [gradient release];
     
     if (fIcon)
     {
     [tabImage unlockFocus];
     
     [self setImage: tabImage];
+    [tabImage release];
 }
 
 - (void) updateControlTint: (NSNotification *) notification
index 8bc3100c2a8d23f020d1c0409726e80869545065..acf418f072a45917a5203a1a685fffa6f09a9ae4 100644 (file)
     }
 }
 
+- (void) dealloc
+{
+    [fTorrents release];
+    [fTrackers release];
+    [fTrackerCell release];
+    
+    [super dealloc];
+}
 
 - (void) setInfoForTorrents: (NSArray *) torrents
 {
     //don't check if it's the same in case the metadata changed
-    fTorrents = torrents;
+    [fTorrents release];
+    fTorrents = [torrents retain];
     
     fSet = NO;
 }
         NSArray * oldTrackers = fTrackers;
         
         if ([fTorrents count] == 1)
-            fTrackers = [[fTorrents objectAtIndex: 0] allTrackerStats];
+            fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
         else
         {
             fTrackers = [[NSMutableArray alloc] init];
         else
             [fTrackerTable reloadData];
         
+        [oldTrackers release];
     }
     else
     {
         NSIndexSet * addedIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange([fTrackers count]-2, 2)];
         NSArray * tierAndTrackerBeingAdded = [fTrackers objectsAtIndexes: addedIndexes];
         
-        fTrackers = [[fTorrents objectAtIndex: 0] allTrackerStats];
+        [fTrackers release];
+        fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
         [fTrackers addObjectsFromArray: tierAndTrackerBeingAdded];
         
         [fTrackerTable setTrackers: fTrackers];
 
 - (void) clearView
 {
+    [fTrackers release];
     fTrackers = nil;
 }
 
         NSBeep();
     
     //reset table with either new or old value
-    fTrackers = [torrent allTrackerStats];
+    [fTrackers release];
+    fTrackers = [[torrent allTrackerStats] retain];
     
     [fTrackerTable setTrackers: fTrackers];
     [fTrackerTable reloadData];
     {
         if (numberSelected == 0)
         {
+            [fTrackers release];
             fTrackers = nil;
             
             [fTrackerTable setTrackers: nil];
         NSInteger result = [alert runModal];
         if ([[alert suppressionButton] state] == NSOnState)
             [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningRemoveTrackers"];
+        [alert release];
         
         if (result != NSAlertFirstButtonReturn)
             return;
         [torrent removeTrackers: [removeIdentifiers objectForKey: torrent]];
     
     //reset table with either new or old value
+    [fTrackers release];
     fTrackers = [[NSMutableArray alloc] init];
     for (Torrent * torrent in fTorrents)
         [fTrackers addObjectsFromArray: [torrent allTrackerStats]];
index 11cf6119adaf4861b24087a585071184011268ad..bac0c22aff24eb80f8c276ba3e79b349dbd89143 100644 (file)
@@ -140,8 +140,16 @@ typedef enum
     if ([fViewController respondsToSelector: @selector(saveViewSize)])
         [fViewController saveViewSize];
     
+    [fGeneralViewController dealloc];
+    [fActivityViewController dealloc];
+    [fTrackersViewController dealloc];
+    [fPeersViewController dealloc];
+    [fFileViewController dealloc];
+    [fOptionsViewController dealloc];
     
+    [fTorrents release];
     
+    [super dealloc];
 }
 
 - (void) setInfoForTorrents: (NSArray *) torrents
@@ -149,7 +157,8 @@ typedef enum
     if (fTorrents && [fTorrents isEqualToArray: torrents])
         return;
     
-    fTorrents = torrents;
+    [fTorrents release];
+    fTorrents = [torrents retain];
     
     [self resetInfo];
 }
index f3a0774d7a9fceded648caa4b2b4de4f8d882682..cefa0945d162f08f9f9c5a6317af1e6bcf294a49 100644 (file)
     filterButtonFrame.origin.x -= NSWidth(clearButtonFrame) - oldClearButtonWidth;
     [fFilterField setFrame: filterButtonFrame];
     
-    fAttributes = [[[[fMessageTable tableColumnWithIdentifier: @"Message"] dataCell] attributedStringValue]
-                    attributesAtIndex: 0 effectiveRange: NULL];
+    fAttributes = [[[[[fMessageTable tableColumnWithIdentifier: @"Message"] dataCell] attributedStringValue]
+                    attributesAtIndex: 0 effectiveRange: NULL] retain];
     
     //select proper level in popup button
     switch ([[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"])
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
     [fTimer invalidate];
+    [fLock release];
     
+    [fMessages release];
+    [fDisplayedMessages release];
     
+    [fAttributes release];
     
+    [super dealloc];
 }
 
 - (void) windowDidBecomeKey: (NSNotification *) notification
             NSSortDescriptor * descriptor = [NSSortDescriptor sortDescriptorWithKey: @"Index" ascending: YES];
             NSArray * descriptors = [[NSArray alloc] initWithObjects: descriptor, nil];
             NSArray * sortedMessages = [fDisplayedMessages sortedArrayUsingDescriptors: descriptors];
+            [descriptors release];
             
             //create the text to output
             NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [sortedMessages count]];
                 [alert setAlertStyle: NSWarningAlertStyle];
                 
                 [alert runModal];
+                [alert release];
             }
         }
     }];
index dbf701017dbb4a6b62d61da1997e4e9bfde45225..8e54201e2130278ece26968dbb4110b5df6d8884 100644 (file)
@@ -39,7 +39,7 @@
     
     [coloredImage unlockFocus];
     
-    return coloredImage;
+    return [coloredImage autorelease];
 }
 
 @end
index 24bfb95d31ebad363c87253d9346173b59b7bfad..6c209b39cafdba93843eea41541e9d8df037ee42 100644 (file)
@@ -31,7 +31,7 @@
     if (fromIndex == toIndex)
         return;
     
-    id object = [self objectAtIndex: fromIndex];
+    id object = [[self objectAtIndex: fromIndex] retain];
     
     //shift objects - more efficient than simply removing the object and re-inserting the object
     if (fromIndex < toIndex)
@@ -46,6 +46,7 @@
     }
     [self replaceObjectAtIndex: toIndex withObject: object];
     
+    [object release];
 }
 
 @end
index 2584583a0def77dc379bbb940d8cd25c3f61f372..fbbf12726b4b1496755d7f9fffe37d3cc198e9c2 100644 (file)
@@ -50,7 +50,7 @@
 
 + (NSString *) formattedUInteger: (NSUInteger) value
 {
-    NSNumberFormatter * numberFormatter = [[NSNumberFormatter alloc] init];
+    NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
     [numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
     [numberFormatter setMaximumFractionDigits: 0];
     
     [numberFormatter setMaximumFractionDigits: decimals];
     
     NSString * fileSizeString = [numberFormatter stringFromNumber: [NSNumber numberWithFloat: convertedSize]];
+    [numberFormatter release];
     
     if (!notAllowedUnit || ![unit isEqualToString: notAllowedUnit])
         fileSizeString = [fileSizeString stringByAppendingFormat: @" %@", unit];
index 60bf794b292183bd513acd43ecb6a4dbb2ac4c06..47a52fdf2f064d833309fec21bbbbf964ca34ee8 100644 (file)
 #import "PeerProgressIndicatorCell.h"
 #import "NSStringAdditions.h"
 
+#import "transmission.h" // required by utils.h
+#import "utils.h"
+
 @implementation PeerProgressIndicatorCell
 
+- (id) copyWithZone: (NSZone *) zone
+{
+    PeerProgressIndicatorCell * copy = [super copyWithZone: zone];
+    copy->fAttributes = [fAttributes retain];
+    
+    return copy;
+}
+
+- (void) dealloc
+{
+    [fAttributes release];
+    [super dealloc];
+}
+
 - (void) setSeed: (BOOL) seed
 {
     fSeed = seed;
@@ -43,6 +60,7 @@
             
             fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: [NSFont systemFontOfSize: 11.0], NSFontAttributeName,
                                                                             paragraphStyle, NSParagraphStyleAttributeName, nil];
+            [paragraphStyle release];
         }
         
         [[NSString percentString: [self floatValue] longDecimals: NO] drawInRect: cellFrame withAttributes: fAttributes];
     else
     {
         //attributes not needed anymore
-        fAttributes = nil;
+        if (fAttributes)
+        {
+            [fAttributes release];
+            fAttributes = nil;
+        }
         
         [super drawWithFrame: cellFrame inView: controlView];
         if (fSeed)
index e45e746c6c35babb989009c9b9385add023f5e4d..b72fdc854badc95205a684f48beb9c5d37a2b8c5 100644 (file)
@@ -32,7 +32,7 @@
     
     NSColor * fGreenAvailabilityColor, * fBluePieceColor;
     
-    __unsafe_unretained Torrent * fTorrent;
+    Torrent * fTorrent;
     NSInteger fNumPieces, fAcross, fWidth, fExtraBorder;
 }
 
index 6019230472051f322f80773ab496256e50ed3d2d..d7e36b6c62c24cdb754925df41eb131adc5f6a43 100644 (file)
@@ -48,8 +48,8 @@ enum
 - (void) awakeFromNib
 {
     //store box colors
-    fGreenAvailabilityColor = [NSColor colorWithCalibratedRed: 0.0 green: 1.0 blue: 0.4 alpha: 1.0];
-    fBluePieceColor = [NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0];
+    fGreenAvailabilityColor = [[NSColor colorWithCalibratedRed: 0.0 green: 1.0 blue: 0.4 alpha: 1.0] retain];
+    fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
     
     //actually draw the box
     [self setTorrent: nil];
@@ -59,7 +59,10 @@ enum
 {
     tr_free(fPieces);
     
+    [fGreenAvailabilityColor release];
+    [fBluePieceColor release];
     
+    [super dealloc];
 }
 
 - (void) setTorrent: (Torrent *) torrent
@@ -84,9 +87,11 @@ enum
     NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.4]
                                 endingColor: [NSColor colorWithCalibratedWhite: 0.2 alpha: 0.4]];
     [gradient drawInRect: [self bounds] angle: 90.0];
+    [gradient release];
     [back unlockFocus];
     
     [self setImage: back];
+    [back release];
     
     [self setNeedsDisplay];
 }
index 6dfe4a1047d3efdecab0c55d19ca441aa1b406c4..6ed2e3ee4a942f8b5ac29bd443cc2c4cf58553cc 100644 (file)
@@ -34,7 +34,7 @@ typedef enum
 
 @interface PortChecker : NSObject
 {    
-    __unsafe_unretained id fDelegate;
+    id fDelegate;
     port_status_t fStatus;
     
     NSURLConnection * fConnection;
index a306eb6a4fd832787d9d1bf088c6a4421e6861a9..5d5eb9f0ebe40cb8a0d9ebeeb2ec66bed3bcfa50 100644 (file)
@@ -58,6 +58,9 @@
 {
     [fTimer invalidate];
     
+    [fConnection release];
+    [fPortProbeData release];
+    [super dealloc];
 }
 
 - (port_status_t) status
@@ -92,6 +95,7 @@
 - (void) connectionDidFinishLoading: (NSURLConnection *) connection
 {
     NSString * probeString = [[NSString alloc] initWithData: fPortProbeData encoding: NSUTF8StringEncoding];
+    [fPortProbeData release];
     fPortProbeData = nil;
     
     if (probeString)
             NSLog(@"Unable to get port status: invalid response (%@)", probeString);
             [self callBackWithStatus: PORT_STATUS_ERROR];
         }
+        [probeString release];
     }
     else
     {
index 4017009fc9c96a8c1fae5d8769406cb7b7ad89a6..bacea960b27b7c09332ad02f648cd38e7e8079e0 100644 (file)
@@ -25,5 +25,7 @@
 #import <Cocoa/Cocoa.h>
 
 @interface PredicateEditorRowTemplateAny : NSPredicateEditorRowTemplate
+{
+}
 
 @end
index 540d1a3013ea53cfbbdb3b0ebf16ec24fc0c865b..a5489017508b342171b7caa872b3f3f828d8020e 100644 (file)
@@ -127,7 +127,7 @@ tr_session * fHandle;
         
         fRPCWhitelistArray = [[fDefaults arrayForKey: @"RPCWhitelist"] mutableCopy];
         if (!fRPCWhitelistArray)
-            fRPCWhitelistArray = [NSMutableArray arrayWithObject: @"127.0.0.1"];
+            fRPCWhitelistArray = [[NSMutableArray arrayWithObject: @"127.0.0.1"] retain];
         [self updateRPCWhitelist];
         
         //reset old Sparkle settings from previous versions
@@ -155,10 +155,14 @@ tr_session * fHandle;
     if (fPortChecker)
     {
         [fPortChecker cancelProbe];
+        [fPortChecker release];
     }
     
+    [fRPCWhitelistArray release];
     
+    [fRPCPassword release];
     
+    [super dealloc];
 }
 
 - (void) awakeFromNib
@@ -172,6 +176,7 @@ tr_session * fHandle;
     [toolbar setSizeMode: NSToolbarSizeModeRegular];
     [toolbar setSelectedItemIdentifier: TOOLBAR_GENERAL];
     [[self window] setToolbar: toolbar];
+    [toolbar release];
     
     [self setPrefView: nil];
     
@@ -306,10 +311,11 @@ tr_session * fHandle;
     }
     else
     {
+        [item release];
         return nil;
     }
 
-    return item;
+    return [item autorelease];
 }
 
 - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
@@ -391,6 +397,7 @@ tr_session * fHandle;
         if (fPortChecker)
         {
             [fPortChecker cancelProbe];
+            [fPortChecker release];
         }
         BOOL delay = natStatusChanged || tr_sessionIsPortForwardingEnabled(fHandle);
         fPortChecker = [[PortChecker alloc] initForPort: fPeerPort delay: delay withDelegate: self];
@@ -418,6 +425,7 @@ tr_session * fHandle;
             NSAssert1(NO, @"Port checker returned invalid status: %d", [fPortChecker status]);
             break;
     }
+    [fPortChecker release];
     fPortChecker = nil;
 }
 
@@ -428,7 +436,7 @@ tr_session * fHandle;
     NSArray * directories = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory,
                                 NSUserDomainMask | NSLocalDomainMask | NSSystemDomainMask, YES);
     
-    for (__strong NSString * directory in directories)
+    for (NSString * directory in directories)
     {
         directory = [directory stringByAppendingPathComponent: @"Sounds"];
         
@@ -436,7 +444,7 @@ tr_session * fHandle;
         if ([[NSFileManager defaultManager] fileExistsAtPath: directory isDirectory: &isDirectory] && isDirectory)
         {
             NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: directory error: NULL];
-            for (__strong NSString * sound in directoryContents)
+            for (NSString * sound in directoryContents)
             {
                 sound = [sound stringByDeletingPathExtension];
                 if ([NSSound soundNamed: sound])
@@ -693,7 +701,7 @@ tr_session * fHandle;
 
 + (NSDate *) timeSumToDate: (NSInteger) sum
 {
-    NSDateComponents * comps = [[NSDateComponents alloc] init];
+    NSDateComponents * comps = [[[NSDateComponents alloc] init] autorelease];
     [comps setHour: sum / 60];
     [comps setMinute: sum % 60];
     
@@ -702,7 +710,8 @@ tr_session * fHandle;
 
 - (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
 {
-    fInitialString = [control stringValue];
+    [fInitialString release];
+    fInitialString = [[control stringValue] retain];
     
     return YES;
 }
@@ -713,6 +722,7 @@ tr_session * fHandle;
     if (fInitialString)
     {
         [control setStringValue: fInitialString];
+        [fInitialString release];
         fInitialString = nil;
     }
     return NO;
@@ -748,7 +758,7 @@ tr_session * fHandle;
 - (void) setDefaultForMagnets: (id) sender
 {
     NSString * bundleID = [[NSBundle mainBundle] bundleIdentifier];
-    const OSStatus result = LSSetDefaultHandlerForURLScheme((CFStringRef)@"magnet", (__bridge CFStringRef)bundleID);
+    const OSStatus result = LSSetDefaultHandlerForURLScheme((CFStringRef)@"magnet", (CFStringRef)bundleID);
     if (result != noErr)
         NSLog(@"Failed setting default magnet link handler");
 }
@@ -972,6 +982,7 @@ tr_session * fHandle;
 
 - (void) setRPCPassword: (id) sender
 {
+    [fRPCPassword release];
     fRPCPassword = [[sender stringValue] copy];
     
     const char * password = [[sender stringValue] UTF8String];
@@ -987,6 +998,7 @@ tr_session * fHandle;
     SecKeychainFindGenericPassword(NULL, strlen(RPC_KEYCHAIN_SERVICE), RPC_KEYCHAIN_SERVICE,
         strlen(RPC_KEYCHAIN_NAME), RPC_KEYCHAIN_NAME, &passwordLength, (void **)&password, NULL);
     
+    [fRPCPassword release];
     if (password != NULL)
     {
         char fullPassword[passwordLength+1];
index 7a3c04cedd5c528dfdefc4222533deb3de2718ec..58678ab4ecc2a7b8a09e1dc9409774c45240d2b2 100644 (file)
@@ -25,5 +25,7 @@
 #import <Cocoa/Cocoa.h>
 
 @interface PrefsWindow : NSWindow
+{
+}
 
 @end
index a8fdc27ba1cba0f021bdd8025ea39b42ca1b144d..0c783b7cf566405bbfedaaf73601e5f908a70452 100644 (file)
@@ -38,7 +38,9 @@
     NSColor * color3 = [NSColor colorWithCalibratedRed: redComponent * 0.85 green: greenComponent * 0.85 blue: blueComponent * 0.85
                         alpha: alpha];
     
-    return [[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5, baseColor, 1.0, nil];
+    NSGradient * progressGradient = [[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5,
+                                        baseColor, 1.0, nil];
+    return [progressGradient autorelease];
 }
 
 @end
index 30715e1568e3297e6d6c97e77db38e25a6dec863..c72c8162812a944381aa7437ad5c0c85fa135df7 100644 (file)
@@ -126,6 +126,7 @@ tr_session * fLib;
 {
     [fTimer invalidate];
     
+    [fStatsWindowInstance autorelease];
     fStatsWindowInstance = nil;
 }
 
index bda2f3a81a5b25fbac6cef1ec6a1ae57117fe7a6..72c0d98529a9cf3e83f3eb781cc8b8b2154fd8d4 100644 (file)
@@ -90,6 +90,7 @@ typedef enum
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
+    [super dealloc];
 }
 
 - (void) updateWithDownload: (CGFloat) dlRate upload: (CGFloat) ulRate
index 68b4965a402afc32640ec49c4343b32c6b2a391f..46c331fd9c0da914c07c9c4b3ceb5e498685e844 100644 (file)
@@ -52,6 +52,8 @@
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
+    [fGradient release];
+    [super dealloc];
 }
 
 - (BOOL) mouseDownCanMoveWindow
index d0abc570b3a180da0692e0d7b229ae81435d4181..6132557d36218d4c591ba8049832bb522243a945 100644 (file)
@@ -62,7 +62,7 @@
 
 void startQueueCallback(tr_torrent * torrent, void * torrentData)
 {
-    [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(startQueue) withObject: nil waitUntilDone: NO];
+    [(Torrent *)torrentData performSelectorOnMainThread: @selector(startQueue) withObject: nil waitUntilDone: NO];
 }
 
 void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, bool wasRunning, void * torrentData)
@@ -71,23 +71,23 @@ void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, bo
     {
         NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt: status], @"Status",
                                [NSNumber numberWithBool: wasRunning], @"WasRunning", nil];
-        [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:) withObject: dict waitUntilDone: NO];
+        [(Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:) withObject: dict waitUntilDone: NO];
     }
 }
 
 void ratioLimitHitCallback(tr_torrent * torrent, void * torrentData)
 {
-    [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(ratioLimitHit) withObject: nil waitUntilDone: NO];
+    [(Torrent *)torrentData performSelectorOnMainThread: @selector(ratioLimitHit) withObject: nil waitUntilDone: NO];
 }
 
 void idleLimitHitCallback(tr_torrent * torrent, void * torrentData)
 {
-    [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(idleLimitHit) withObject: nil waitUntilDone: NO];
+    [(Torrent *)torrentData performSelectorOnMainThread: @selector(idleLimitHit) withObject: nil waitUntilDone: NO];
 }
 
 void metadataCallback(tr_torrent * torrent, void * torrentData)
 {
-    [(__bridge Torrent *)torrentData performSelectorOnMainThread: @selector(metadataRetrieved) withObject: nil waitUntilDone: NO];
+    [(Torrent *)torrentData performSelectorOnMainThread: @selector(metadataRetrieved) withObject: nil waitUntilDone: NO];
 }
 
 int trashDataFile(const char * filename)
@@ -211,6 +211,20 @@ int trashDataFile(const char * filename)
     
     if (fFileStat)
         tr_torrentFilesFree(fFileStat, [self fileCount]);
+    
+    [fPreviousFinishedIndexes release];
+    [fPreviousFinishedIndexesDate release];
+    
+    [fHashString release];
+    
+    [fIcon release];
+    
+    [fFileList release];
+    [fFlatFileList release];
+    
+    [fTimeMachineExclude release];
+    
+    [super dealloc];
 }
 
 - (NSString *) description
@@ -220,7 +234,7 @@ int trashDataFile(const char * filename)
 
 - (id) copyWithZone: (NSZone *) zone
 {
-    return self;
+    return [self retain];
 }
 
 - (void) closeRemoveTorrent: (BOOL) trashFiles
@@ -229,6 +243,7 @@ int trashDataFile(const char * filename)
     if (fTimeMachineExclude)
     {
         [self setTimeMachineExclude: NO forPath: fTimeMachineExclude];
+        [fTimeMachineExclude release];
         fTimeMachineExclude = nil;
     }
     
@@ -267,8 +282,10 @@ int trashDataFile(const char * filename)
 
 - (void) setPreviousFinishedPieces: (NSIndexSet *) indexes
 {
-    fPreviousFinishedIndexes = indexes;
+    [fPreviousFinishedIndexes release];
+    fPreviousFinishedIndexes = [indexes retain];
     
+    [fPreviousFinishedIndexesDate release];
     fPreviousFinishedIndexesDate = indexes != nil ? [[NSDate alloc] init] : nil;
 }
 
@@ -513,6 +530,7 @@ int trashDataFile(const char * filename)
         [alert addButtonWithTitle: NSLocalizedString(@"OK", "Move inside itself alert -> button")];
         
         [alert runModal];
+        [alert release];
         
         return;
     }
@@ -534,6 +552,7 @@ int trashDataFile(const char * filename)
         [alert addButtonWithTitle: NSLocalizedString(@"OK", "Move error alert -> button")];
         
         [alert runModal];
+        [alert release];
     }
     
     [self updateTimeMachineExclude];
@@ -577,6 +596,7 @@ int trashDataFile(const char * filename)
             const NSInteger result = [alert runModal];
             if ([[alert suppressionButton] state] == NSOnState)
                 [fDefaults setBool: NO forKey: @"WarningRemainingSpace"];
+            [alert release];
             
             return result != NSAlertFirstButtonReturn;
         }
@@ -591,8 +611,8 @@ int trashDataFile(const char * filename)
     
     #warning replace kGenericFolderIcon stuff with NSImageNameFolder on 10.6
     if (!fIcon)
-        fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: [self isFolder] ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
-                                                                                : [[self name] pathExtension]];
+        fIcon = [[[NSWorkspace sharedWorkspace] iconForFileType: [self isFolder] ? NSFileTypeForHFSTypeCode(kGenericFolderIcon)
+                                                                                : [[self name] pathExtension]] retain];
     return fIcon;
 }
 
@@ -635,6 +655,7 @@ int trashDataFile(const char * filename)
         
         TrackerNode * tracker = [[TrackerNode alloc] initWithTrackerStat: &stats[i] torrent: self];
         [trackers addObject: tracker];
+        [tracker release];
     }
     
     tr_torrentTrackersFree(stats, count);
@@ -1527,6 +1548,7 @@ int trashDataFile(const char * filename)
     if (fTimeMachineExclude)
     {
         [self setTimeMachineExclude: NO forPath: fTimeMachineExclude];
+        [fTimeMachineExclude release];
         fTimeMachineExclude = nil;
     }
     
@@ -1534,7 +1556,7 @@ int trashDataFile(const char * filename)
     if (currentLocation)
     {
         [self setTimeMachineExclude: YES forPath: currentLocation];
-        fTimeMachineExclude = currentLocation;
+        fTimeMachineExclude = [currentLocation retain];
     }
 }
 
@@ -1629,17 +1651,18 @@ int trashDataFile(const char * filename)
         
         if (!fHandle)
         {
+            [self release];
             return nil;
         }
     }
 
     fInfo = tr_torrentInfo(fHandle);
     
-    tr_torrentSetQueueStartCallback(fHandle, startQueueCallback, (__bridge void *)(self));
-    tr_torrentSetCompletenessCallback(fHandle, completenessChangeCallback, (__bridge void *)(self));
-    tr_torrentSetRatioLimitHitCallback(fHandle, ratioLimitHitCallback, (__bridge void *)(self));
-    tr_torrentSetIdleLimitHitCallback(fHandle, idleLimitHitCallback, (__bridge void *)(self));
-    tr_torrentSetMetadataCallback(fHandle, metadataCallback, (__bridge void *)(self));
+    tr_torrentSetQueueStartCallback(fHandle, startQueueCallback, self);
+    tr_torrentSetCompletenessCallback(fHandle, completenessChangeCallback, self);
+    tr_torrentSetRatioLimitHitCallback(fHandle, ratioLimitHitCallback, self);
+    tr_torrentSetIdleLimitHitCallback(fHandle, idleLimitHitCallback, self);
+    tr_torrentSetMetadataCallback(fHandle, metadataCallback, self);
     
     fHashString = [[NSString alloc] initWithUTF8String: fInfo->hashString];
     
@@ -1654,7 +1677,7 @@ int trashDataFile(const char * filename)
     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:)
         name: @"GroupValueRemoved" object: nil];
     
-    fTimeMachineExclude = timeMachineExclude;
+    fTimeMachineExclude = [timeMachineExclude retain];
     [self update];
     
     return self;
@@ -1697,6 +1720,7 @@ int trashDataFile(const char * filename)
                 {
                     node = [[FileListNode alloc] initWithFolderName: name path: path torrent: self];
                     [fileList addObject: node];
+                    [node release];
                 }
                 
                 NSMutableArray * trimmedComponents = [NSMutableArray arrayWithArray: [pathComponents subarrayWithRange: NSMakeRange(2, [pathComponents count]-2)]];
@@ -1709,6 +1733,7 @@ int trashDataFile(const char * filename)
                 FileListNode * node = [[FileListNode alloc] initWithFileName: name path: path size: file->length index: i torrent: self];
                 [fileList addObject: node];
                 [flatFileList addObject: node];
+                [node release];
             }
         }
         
@@ -1721,8 +1746,9 @@ int trashDataFile(const char * filename)
     else
     {
         FileListNode * node = [[FileListNode alloc] initWithFileName: [self name] path: @"" size: [self size] index: 0 torrent: self];
-        fFileList = [NSArray arrayWithObject: node];
-        fFlatFileList = fFileList;
+        fFileList = [[NSArray arrayWithObject: node] retain];
+        fFlatFileList = [fFileList retain];
+        [node release];
     }
 }
 
@@ -1758,6 +1784,7 @@ int trashDataFile(const char * filename)
         }
         
         [parent insertChild: node];
+        [node release];
     }
     
     if (isFolder)
@@ -1794,7 +1821,6 @@ int trashDataFile(const char * filename)
     {
         case TR_SEED:
         case TR_PARTIAL_SEED:
-        {
             //simpler to create a new dictionary than to use statusInfo - avoids retention chicanery
             [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self
                 userInfo: [NSDictionary dictionaryWithObject: [statusInfo objectForKey: @"WasRunning"] forKey: @"WasRunning"]];
@@ -1805,19 +1831,19 @@ int trashDataFile(const char * filename)
             if (FSPathMakeRef((const UInt8 *)[dataLocation UTF8String], &ref, NULL) == noErr)
             {
                 NSDictionary * quarantineProperties = [NSDictionary dictionaryWithObject: (NSString *)kLSQuarantineTypeOtherDownload forKey: (NSString *)kLSQuarantineTypeKey];
-                if (LSSetItemAttribute(&ref, kLSRolesAll, kLSItemQuarantineProperties, (__bridge void *)quarantineProperties) != noErr)
+                if (LSSetItemAttribute(&ref, kLSRolesAll, kLSItemQuarantineProperties, quarantineProperties) != noErr)
                     NSLog(@"Failed to quarantine: %@", dataLocation);
             }
             else
                 NSLog(@"Could not find file to quarantine: %@", dataLocation);
             
             break;
-        }
         
         case TR_LEECH:
             [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentRestartedDownloading" object: self];
             break;
     }
+    [statusInfo release];
     
     [self update];
     [self updateTimeMachineExclude];
@@ -1892,7 +1918,7 @@ int trashDataFile(const char * filename)
 
 - (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path
 {
-    CSBackupSetItemExcluded((__bridge CFURLRef)[NSURL fileURLWithPath: path], exclude, true);
+    CSBackupSetItemExcluded((CFURLRef)[NSURL fileURLWithPath: path], exclude, true);
 }
 
 @end
index 3f759d4181dd61d734da91573d2947b725827e56..c984cd8aa4c578e9355a99375d1310f52535292a 100644 (file)
         [fStatusAttributes setObject: [NSFont messageFontOfSize: 9.0] forKey: NSFontAttributeName];
         [fStatusAttributes setObject: paragraphStyle forKey: NSParagraphStyleAttributeName];
         
+        [paragraphStyle release];
         
-        fBluePieceColor = [NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0];
-        fBarBorderColor = [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.2];
-        fBarMinimalBorderColor = [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.015];
+        fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
+        fBarBorderColor = [[NSColor colorWithCalibratedWhite: 0.0 alpha: 0.2] retain];
+        fBarMinimalBorderColor = [[NSColor colorWithCalibratedWhite: 0.0 alpha: 0.015] retain];
     }
        return self;
 }
         [rowInfo setObject: @"Row" forKey: @"Type"];
         NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: cellFrame options: rowOptions owner: controlView userInfo: rowInfo];
         [controlView addTrackingArea: area];
+        [rowInfo release];
+        [area release];
     }
     
     //control button
     NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: controlButtonRect options: controlOptions owner: controlView
                                 userInfo: controlInfo];
     [controlView addTrackingArea: area];
+    [controlInfo release];
+    [area release];
     
     //reveal button
     NSRect revealButtonRect = [self revealButtonRectForBounds: cellFrame];
     area = [[NSTrackingArea alloc] initWithRect: revealButtonRect options: revealOptions owner: controlView
                                 userInfo: revealInfo];
     [controlView addTrackingArea: area];
+    [revealInfo release];
+    [area release];
     
     //action button
     NSRect actionButtonRect = [self iconRectForBounds: cellFrame]; //use the whole icon
     [actionInfo setObject: @"Action" forKey: @"Type"];
     area = [[NSTrackingArea alloc] initWithRect: actionButtonRect options: actionOptions owner: controlView userInfo: actionInfo];
     [controlView addTrackingArea: area];
+    [actionInfo release];
+    [area release];
 }
 
 - (void) setHover: (BOOL) hover
         NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: [groupColor blendedColorWithFraction: 0.7
                                     ofColor: [NSColor whiteColor]] endingColor: darkGroupColor];
         [gradient drawInBezierPath: bp angle: 90.0];
+        [gradient release];
     }
     
     const BOOL error = [torrent isAnyErrorOrWarning];
     [bitmap drawInRect: barRect fromRect: NSZeroRect operation: NSCompositeSourceOver
         fraction: ([fDefaults boolForKey: @"SmallView"] ? 0.25 : 1.0) respectFlipped: YES hints: nil];
 
+    [bitmap release];
 }
 
 - (NSRect) rectForMinimalStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
 - (NSAttributedString *) attributedTitle
 {
     NSString * title = [(Torrent *)[self representedObject] name];
-    return [[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes];
+    return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease];
 }
 
 - (NSAttributedString *) attributedStatusString: (NSString *) string
 {
-    return [[NSAttributedString alloc] initWithString: string attributes: fStatusAttributes];
+    return [[[NSAttributedString alloc] initWithString: string attributes: fStatusAttributes] autorelease];
 }
 
 - (NSString *) buttonString
index d7e5d87b2701502f26c9a027ca5bfc18645a6b2c..d1ad5731d40df66ea4a4f5e05bd978d3cbee470f 100644 (file)
     return self;
 }
 
+- (void) dealloc
+{
+    [fTorrents release];
+    [super dealloc];
+}
 
 - (NSString *) description
 {
index c62e2ea3c919417c70aff3c963364ed3672d12c6..41c9549c07bb18c50fee62ce992f4f460ed42e6d 100644 (file)
 - (void) dealloc
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
+    
+    [fCollapsedGroups release];
+    
+    [fPiecesBarAnimation release];
+    [fMenuTorrent release];
+    
+    [fSelectedValues release];
+    
+    [fTorrentCell release];
+    
+    [super dealloc];
 }
 
 - (void) awakeFromNib
     
     //if pushing a button, don't change the selected rows
     if (pushed)
-        fSelectedValues = [self selectedValues];
+        fSelectedValues = [[self selectedValues] retain];
     
     [super mouseDown: event];
     
+    [fSelectedValues release];
     fSelectedValues = nil;
     
     //avoid weird behavior when showing menu by doing this after mouse down
         [infoViewController setInfoForTorrents: [NSArray arrayWithObject: torrent]];
         [infoViewController updateInfo];
         
+        [infoViewController release];
+        [popover release];
     }
     else
     {
         //update file action menu
-        fMenuTorrent = [self itemAtRow: row];
+        fMenuTorrent = [[self itemAtRow: row] retain];
         
         //update global limit check
         [fGlobalLimitItem setState: [fMenuTorrent usesGlobalSpeedLimit] ? NSOnState : NSOffState];
         location = [self convertPoint: location toView: self];
         [fActionMenu popUpMenuPositioningItem: nil atLocation: location inView: self];
         
+        [fMenuTorrent release];
         fMenuTorrent = nil;
     }
 }
                 [item setTarget: self];
                 [item setRepresentedObject: [NSNumber numberWithInt: speedLimitActionValue[i]]];
                 [menu addItem: item];
+                [item release];
             }
         }
         
                 [item setTarget: self];
                 [item setRepresentedObject: [NSNumber numberWithFloat: ratioLimitActionValue[i]]];
                 [menu addItem: item];
+                [item release];
             }
         }
         
 
 - (void) togglePiecesBar
 {
+    //stop previous animation
+    if (fPiecesBarAnimation)
+        [fPiecesBarAnimation release];
+    
     NSMutableArray * progressMarks = [NSMutableArray arrayWithCapacity: 16];
-    for (NSAnimationProgress i = 1.0/16; i <= 1.0; i += 1.0/16)
+    for (NSAnimationProgress i = 0.0625; i <= 1.0; i += 0.0625)
         [progressMarks addObject: [NSNumber numberWithFloat: i]];
     
     fPiecesBarAnimation = [[NSAnimation alloc] initWithDuration: TOGGLE_PROGRESS_SECONDS animationCurve: NSAnimationEaseIn];
 {
     if (animation == fPiecesBarAnimation)
     {
+        [fPiecesBarAnimation release];
         fPiecesBarAnimation = nil;
     }
 }
index f3316428d461325ee53ea14123281c710d787537..ad0a33102617d73e6f4a677407a7dbb60663ec4c 100644 (file)
@@ -83,10 +83,29 @@ NSMutableSet * fTrackerIconLoading;
                                 [NSFont messageFontOfSize: 9.0], NSFontAttributeName,
                                 paragraphStyle, NSParagraphStyleAttributeName, nil];
         
+        [paragraphStyle release];
     }
     return self;
 }
 
+- (void) dealloc
+{
+    [fNameAttributes release];
+    [fStatusAttributes release];
+    
+    [super dealloc];
+}
+
+- (id) copyWithZone: (NSZone *) zone
+{
+    TrackerCell * copy = [super copyWithZone: zone];
+    
+    copy->fNameAttributes = [fNameAttributes retain];
+    copy->fStatusAttributes = [fStatusAttributes retain];
+    
+    return copy;
+}
+
 - (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
 {
     //icon
@@ -223,6 +242,7 @@ NSMutableSet * fTrackerIconLoading;
         if (icon)
         {
             [fTrackerIconCache setObject: icon forKey: baseAddress];
+            [icon release];
             
             [[self controlView] setNeedsDisplay: YES];
         }
@@ -282,18 +302,18 @@ NSMutableSet * fTrackerIconLoading;
 - (NSAttributedString *) attributedName
 {
     NSString * name = [(TrackerNode *)[self objectValue] host];
-    return [[NSAttributedString alloc] initWithString: name attributes: fNameAttributes];
+    return [[[NSAttributedString alloc] initWithString: name attributes: fNameAttributes] autorelease];
 }
 
 - (NSAttributedString *) attributedStatusWithString: (NSString *) statusString
 {
-    return [[NSAttributedString alloc] initWithString: statusString attributes: fStatusAttributes];
+    return [[[NSAttributedString alloc] initWithString: statusString attributes: fStatusAttributes] autorelease];
 }
 
 - (NSAttributedString *) attributedCount: (NSInteger) count
 {
     NSString * countString = count != -1 ? [NSString stringWithFormat: @"%d", count] : NSLocalizedString(@"N/A", "tracker peer stat");
-    return [[NSAttributedString alloc] initWithString: countString attributes: fStatusAttributes];
+    return [[[NSAttributedString alloc] initWithString: countString attributes: fStatusAttributes] autorelease];
 }
 
 @end
index 26a2c25a12b63442387d7fec065dd4433aeb50f6..aa45cadcf5435695efadd9750eecdece6be73536 100644 (file)
 {
     tr_tracker_stat fStat;
     
-    __unsafe_unretained Torrent * fTorrent;
+    Torrent * fTorrent;
 }
 
-@property (nonatomic, readonly, assign) Torrent * torrent;
+@property (nonatomic, readonly) Torrent * torrent;
 
 - (id) initWithTrackerStat: (tr_tracker_stat *) stat torrent: (Torrent *) torrent;
 
index 570411593f3c61ee01b8d53b308b771a3e81f631..c2649fa1de083ec640c588a4efcb16862f1d2605 100644 (file)
@@ -28,7 +28,6 @@
 @implementation TrackerNode
 
 #warning remove ivars in header when 64-bit only (or it compiles in 32-bit mode)
-#warning make weak when 10.7-only (not assign)
 @synthesize torrent = fTorrent;
 
 - (id) initWithTrackerStat: (tr_tracker_stat *) stat torrent: (Torrent *) torrent
@@ -36,8 +35,7 @@
     if ((self = [super init]))
     {
         fStat = *stat;
-        #warning make __weak when 10.7-only
-        fTorrent = torrent;
+        fTorrent = torrent; //weak reference
     }
     
     return self;
@@ -51,7 +49,7 @@
 - (id) copyWithZone: (NSZone *) zone
 {
     //this object is essentially immutable after initial setup
-    return self;
+    return [self retain];
 }
 
 - (BOOL) isEqual: (id) object
         [dateFormatter setDoesRelativeDateFormatting: YES];
         
         dateString = [dateFormatter stringFromDate: [NSDate dateWithTimeIntervalSince1970: fStat.lastAnnounceTime]];
+        [dateFormatter release];
     }
     else
         dateString = NSLocalizedString(@"N/A", "Tracker last announce");
         [dateFormatter setDoesRelativeDateFormatting: YES];
         
         dateString = [dateFormatter stringFromDate: [NSDate dateWithTimeIntervalSince1970: fStat.lastScrapeTime]];
+        [dateFormatter release];
     }
     else
         dateString = NSLocalizedString(@"N/A", "Tracker last scrape");
index 78cabe55d333ad19e1340291b48d2f2a5dc88592..1ccc7d46cea1752a75d488dc9d4000e567fb8c05 100644 (file)
@@ -28,8 +28,9 @@
 
 @interface TrackerTableView : NSTableView
 {
-    __unsafe_unretained Torrent * fTorrent;
-    __unsafe_unretained NSArray * fTrackers;
+    //weak references
+    Torrent * fTorrent;
+    NSArray * fTrackers;
 }
 
 - (void) setTorrent: (Torrent *) torrent;
index b97557e5a81a560dc10b86ec3f5d3132ba2f3bad..303da55b61021e086bf9684c2ec222d0023d502b 100644 (file)
@@ -2,13 +2,13 @@
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
        <data>
                <int key="IBDocument.SystemTarget">1060</int>
-               <string key="IBDocument.SystemVersion">11D50</string>
-               <string key="IBDocument.InterfaceBuilderVersion">2182</string>
-               <string key="IBDocument.AppKitVersion">1138.32</string>
-               <string key="IBDocument.HIToolboxVersion">568.00</string>
+               <string key="IBDocument.SystemVersion">11B26</string>
+               <string key="IBDocument.InterfaceBuilderVersion">1617</string>
+               <string key="IBDocument.AppKitVersion">1138</string>
+               <string key="IBDocument.HIToolboxVersion">566.00</string>
                <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
                        <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
-                       <string key="NS.object.0">2182</string>
+                       <string key="NS.object.0">1617</string>
                </object>
                <array key="IBDocument.IntegratedClassDependencies">
                        <string>NSTextField</string>
                <array key="IBDocument.PluginDependencies">
                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                </array>
-               <object class="NSMutableDictionary" key="IBDocument.Metadata">
-                       <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
-                       <integer value="1" key="NS.object.0"/>
-               </object>
+               <dictionary class="NSMutableDictionary" key="IBDocument.Metadata"/>
                <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
                        <object class="NSCustomObject" id="1001">
                                <string key="NSClassName">URLSheetWindowController</string>
@@ -49,7 +46,7 @@
                                <nil key="NSUserInterfaceItemIdentifier"/>
                                <string key="NSWindowContentMinSize">{400, 177}</string>
                                <object class="NSView" key="NSWindowView" id="892541411">
-                                       <reference key="NSNextResponder"/>
+                                       <nil key="NSNextResponder"/>
                                        <int key="NSvFlags">256</int>
                                        <array class="NSMutableArray" key="NSSubviews">
                                                <object class="NSTextField" id="1066788818">
@@ -57,8 +54,6 @@
                                                        <int key="NSvFlags">274</int>
                                                        <string key="NSFrame">{{20, 50}, {360, 80}}</string>
                                                        <reference key="NSSuperview" ref="892541411"/>
-                                                       <reference key="NSWindow"/>
-                                                       <reference key="NSNextKeyView" ref="9691643"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSTextFieldCell" key="NSCell" id="139057847">
                                                                <int key="NSCellFlags">-1805517311</int>
@@ -96,8 +91,6 @@
                                                        <int key="NSvFlags">289</int>
                                                        <string key="NSFrame">{{304, 12}, {82, 32}}</string>
                                                        <reference key="NSSuperview" ref="892541411"/>
-                                                       <reference key="NSWindow"/>
-                                                       <reference key="NSNextKeyView"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSButtonCell" key="NSCell" id="62424678">
                                                                <int key="NSCellFlags">604110336</int>
                                                        <int key="NSvFlags">289</int>
                                                        <string key="NSFrame">{{222, 12}, {82, 32}}</string>
                                                        <reference key="NSSuperview" ref="892541411"/>
-                                                       <reference key="NSWindow"/>
-                                                       <reference key="NSNextKeyView" ref="794131740"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSButtonCell" key="NSCell" id="341887532">
                                                                <int key="NSCellFlags">67239424</int>
                                                        <int key="NSvFlags">266</int>
                                                        <string key="NSFrame">{{17, 140}, {366, 17}}</string>
                                                        <reference key="NSSuperview" ref="892541411"/>
-                                                       <reference key="NSWindow"/>
-                                                       <reference key="NSNextKeyView" ref="1066788818"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSTextFieldCell" key="NSCell" id="830118733">
                                                                <int key="NSCellFlags">67239488</int>
                                                </object>
                                        </array>
                                        <string key="NSFrameSize">{400, 177}</string>
-                                       <reference key="NSSuperview"/>
-                                       <reference key="NSWindow"/>
-                                       <reference key="NSNextKeyView" ref="459786882"/>
                                </object>
                                <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
                                <string key="NSMinSize">{400, 199}</string>
                                        </object>
                                        <int key="connectionID">17</int>
                                </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fCancelButton</string>
-                                               <reference key="source" ref="1001"/>
-                                               <reference key="destination" ref="9691643"/>
-                                       </object>
-                                       <int key="connectionID">22</int>
-                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">openURLEndSheet:</string>
                                                <reference key="source" ref="1001"/>
                                                <reference key="destination" ref="794131740"/>
                                        </object>
-                                       <int key="connectionID">23</int>
+                                       <int key="connectionID">18</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <reference key="source" ref="1001"/>
                                                <reference key="destination" ref="9691643"/>
                                        </object>
-                                       <int key="connectionID">24</int>
+                                       <int key="connectionID">19</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                        </object>
                                        <int key="connectionID">21</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fCancelButton</string>
+                                               <reference key="source" ref="1001"/>
+                                               <reference key="destination" ref="9691643"/>
+                                       </object>
+                                       <int key="connectionID">22</int>
+                               </object>
                        </array>
                        <object class="IBMutableOrderedSet" key="objectRecords">
                                <array key="orderedObjects">
                        <nil key="activeLocalization"/>
                        <dictionary class="NSMutableDictionary" key="localizations"/>
                        <nil key="sourceID"/>
-                       <int key="maxID">24</int>
+                       <int key="maxID">22</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <array class="NSMutableArray" key="referencedPartialClassDescriptions">
                                <object class="IBPartialClassDescription">
                                        <string key="className">URLSheetWindowController</string>
                                        <string key="superclassName">NSWindowController</string>
-                                       <dictionary class="NSMutableDictionary" key="actions">
-                                               <string key="openURLCancelEndSheet:">id</string>
-                                               <string key="openURLEndSheet:">id</string>
-                                       </dictionary>
-                                       <dictionary class="NSMutableDictionary" key="actionInfosByName">
-                                               <object class="IBActionInfo" key="openURLCancelEndSheet:">
-                                                       <string key="name">openURLCancelEndSheet:</string>
-                                                       <string key="candidateClassName">id</string>
-                                               </object>
-                                               <object class="IBActionInfo" key="openURLEndSheet:">
-                                                       <string key="name">openURLEndSheet:</string>
-                                                       <string key="candidateClassName">id</string>
-                                               </object>
-                                       </dictionary>
                                        <dictionary class="NSMutableDictionary" key="outlets">
                                                <string key="fCancelButton">NSButton</string>
                                                <string key="fLabelField">NSTextField</string>
                </object>
                <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
                        <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
-                       <real value="1070" key="NS.object.0"/>
+                       <integer value="1060" key="NS.object.0"/>
                </object>
                <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
                <int key="IBDocument.defaultPropertyAccessControl">3</int>
index 69643cf603cbe981bdb5509ef9d85aa2bca1dfe0..b4ac263cf3681aac175cf5afb89d35db49956514 100644 (file)
     IBOutlet NSTextField * fTextField;
     IBOutlet NSButton * fOpenButton, * fCancelButton;
     
-    __unsafe_unretained Controller * fController;
+    Controller * fController;
 }
 
 - (id) initWithController: (Controller *) controller;
+- (void) beginSheetForWindow: (NSWindow *) window;
 
-- (IBAction) openURLEndSheet: (id) sender;
-- (IBAction) openURLCancelEndSheet: (id) sender;
-
-- (NSString *) urlString;
+- (void) openURLEndSheet: (id) sender;
+- (void) openURLCancelEndSheet: (id) sender;
 
 @end
index a4d19daeea597c30e85d27c4c1aef3343dc41da1..aad117f21925a9eedfdafce53d591ff50b2fb8c2 100644 (file)
@@ -80,21 +80,29 @@ NSString * urlString = nil;
     [fCancelButton setFrame: cancelFrame];
 }
 
-- (IBAction) openURLEndSheet: (id) sender
+- (IBAction) beginSheetForWindow: (NSWindow *) window
+{
+    [NSApp beginSheet: [self window] modalForWindow: window modalDelegate: self
+        didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
+}
+
+- (void) openURLEndSheet: (id) sender
 {
     [[self window] orderOut: sender];
     [NSApp endSheet: [self window] returnCode: 1];
 }
 
-- (IBAction) openURLCancelEndSheet: (id) sender
+- (void) openURLCancelEndSheet: (id) sender
 {
     [[self window] orderOut: sender];
     [NSApp endSheet: [self window] returnCode: 0];
 }
 
-- (NSString *) urlString
+- (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
 {
-    return [fTextField stringValue];
+    [urlString release];
+    urlString = [[fTextField stringValue] retain];
+    [fController urlSheetDidEnd: self url: urlString returnCode: returnCode];
 }
 
 - (void) controlTextDidChange: (NSNotification *) notification