diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index 755af50f..26cc113d 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -15,6 +15,7 @@ ARCHS = $(ARCHS_STANDARD) MACOSX_DEPLOYMENT_TARGET = 10.7 GCC_PREPROCESSOR_DEFINITIONS = FINISH_INSTALL_TOOL_NAME=$(FINISH_INSTALL_TOOL_NAME) +CLANG_ENABLE_OBJC_ARC = YES // Enable warnings CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES diff --git a/Configurations/ConfigTestApp.xcconfig b/Configurations/ConfigTestApp.xcconfig index 16057d7c..35e7e543 100644 --- a/Configurations/ConfigTestApp.xcconfig +++ b/Configurations/ConfigTestApp.xcconfig @@ -4,3 +4,4 @@ INFOPLIST_FILE = TestApplication/TestApplication-Info.plist PRODUCT_NAME = Sparkle Test App WRAPPER_EXTENSION = app ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon +CLANG_ENABLE_OBJC_ARC = NO diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 9cb56d7b..c70080ac 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -87,7 +87,7 @@ 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */; }; 6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */; settings = {ATTRIBUTES = (); }; }; 6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */; settings = {ATTRIBUTES = (); }; }; - 6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; }; + 6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */; settings = {ATTRIBUTES = (); }; }; 6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */; }; 610EC1E00CF3A5FE00AE239E /* NTSynchronousTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */; }; @@ -152,7 +152,7 @@ 61B93C090DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B93C070DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h */; settings = {ATTRIBUTES = (); }; }; 61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B93C080DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m */; }; 61CFB3290E385186007A1735 /* Sparkle.pch in Headers */ = {isa = PBXBuildFile; fileRef = 61CFB3280E385186007A1735 /* Sparkle.pch */; }; - 61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6129C0B90E0B79810062CE76 /* SUPipedUnarchiver.m */; }; + 61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6129C0B90E0B79810062CE76 /* SUPipedUnarchiver.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 61EF67560E25B58D00F754E0 /* SUHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 61EF67550E25B58D00F754E0 /* SUHost.m */; }; 61EF67590E25C5B400F754E0 /* SUHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 61EF67580E25C5B400F754E0 /* SUHost.h */; }; 61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; }; @@ -292,7 +292,7 @@ 14732BC41960F3FF00593899 /* sign_update.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sign_update.sh; sourceTree = ""; }; 14732BC91960F70A00593899 /* make-release-package.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "make-release-package.sh"; sourceTree = ""; }; 14732BD219610A1800593899 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; - 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdaterTest.m; path = Tests/SUUpdaterTest.m; sourceTree = ""; }; + 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdaterTest.m; path = Tests/SUUpdaterTest.m; sourceTree = ""; usesTabs = 0; }; 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUVersionDisplayProtocol.h; sourceTree = ""; }; 4607BEA21948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Sparkle.strings; sourceTree = ""; }; 4607BEA31948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nb; path = nb.lproj/SUAutomaticUpdateAlert.xib; sourceTree = ""; }; diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index bf7bd6a3..fb12c9d5 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -55,7 +55,7 @@ static const NSTimeInterval SUParentQuitCheckInterval = .5; executablepath = execpath; parentprocessid = ppid; folderpath = infolderpath; - selfPath = [inSelfPath retain]; + selfPath = inSelfPath; shouldRelaunch = relaunch; shouldShowUI = showUI; @@ -64,7 +64,7 @@ static const NSTimeInterval SUParentQuitCheckInterval = .5; if( alreadyTerminated ) [self parentHasQuit]; else - watchdogTimer = [[NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES] retain]; + watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES]; return self; } @@ -73,30 +73,15 @@ static const NSTimeInterval SUParentQuitCheckInterval = .5; -(void) dealloc { [longInstallationTimer invalidate]; - [longInstallationTimer release]; - longInstallationTimer = nil; - - [selfPath release]; - selfPath = nil; - - [installationPath release]; - - [watchdogTimer release]; - watchdogTimer = nil; - - [host release]; - host = nil; - - [super dealloc]; } -(void) parentHasQuit { [watchdogTimer invalidate]; - longInstallationTimer = [[NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit + longInstallationTimer = [NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit target: self selector: @selector(showAppIconInDock:) - userInfo:nil repeats:NO] retain]; + userInfo:nil repeats:NO]; if( folderpath ) [self install]; @@ -154,7 +139,6 @@ static const NSTimeInterval SUParentQuitCheckInterval = .5; [statusCtl beginActionWithTitle: SULocalizedString(@"Installing update...",@"") maxProgressValue: 0 statusText: @""]; [statusCtl showWindow: self]; - [statusCtl release]; } [SUInstaller installFromUpdateFolder:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:folderpath length:strlen(folderpath)] @@ -209,13 +193,15 @@ int main (int argc, const char * argv[]) } [NSApplication sharedApplication]; - [[[TerminationListener alloc] initWithHostPath: (argc > 1) ? argv[1] : NULL + TerminationListener *termListen = [[TerminationListener alloc] initWithHostPath: (argc > 1) ? argv[1] : NULL executablePath: (argc > 2) ? argv[2] : NULL parentProcessId: (argc > 3) ? atoi(argv[3]) : 0 folderPath: (argc > 4) ? argv[4] : NULL shouldRelaunch: (argc > 5) ? !!atoi(argv[5]) : YES shouldShowUI: shouldShowUI - selfPath: selfPath] autorelease]; + selfPath: selfPath]; + + [termListen class]; [[NSApplication sharedApplication] run]; } diff --git a/Sparkle/SUAppcast.h b/Sparkle/SUAppcast.h index 7f835dd0..d2236759 100644 --- a/Sparkle/SUAppcast.h +++ b/Sparkle/SUAppcast.h @@ -17,11 +17,11 @@ @private NSArray *items; NSString *userAgentString; - id delegate; + id __weak delegate; NSString *downloadFilename; NSURLDownload *download; } -@property (assign) id delegate; +@property (weak) id delegate; @property (copy) NSString *userAgentString; - (void)fetchAppcastFromURL:(NSURL *)url; diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index 08d863f0..0ff296e5 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -34,7 +34,7 @@ @interface SUAppcast () @property (copy) NSString *downloadFilename; -@property (retain) NSURLDownload *download; +@property (strong) NSURLDownload *download; @property (copy) NSArray *items; - (void)reportError:(NSError *)error; - (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes; @@ -47,16 +47,6 @@ @synthesize download; @synthesize items; -- (void)dealloc -{ - self.items = nil; - self.userAgentString = nil; - self.downloadFilename = nil; - self.download = nil; - - [super dealloc]; -} - - (void)fetchAppcastFromURL:(NSURL *)url { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; @@ -64,7 +54,7 @@ [request setValue:userAgentString forHTTPHeaderField:@"User-Agent"]; } - self.download = [[[NSURLDownload alloc] initWithRequest:request delegate:self] autorelease]; + self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self]; } - (void)download:(NSURLDownload *) __unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename @@ -95,7 +85,7 @@ { NSUInteger options = 0; options = NSXMLNodeLoadExternalEntitiesSameOriginOnly; - document = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:options error:&error] autorelease]; + document = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:options error:&error]; [[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil]; self.downloadFilename = nil; @@ -187,7 +177,7 @@ } NSString *errString; - SUAppcastItem *anItem = [[[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString] autorelease]; + SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString]; if (anItem) { [appcastItems addObject:anItem]; @@ -203,7 +193,7 @@ if ([appcastItems count]) { - NSSortDescriptor *sort = [[[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO] autorelease]; + NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO]; [appcastItems sortUsingDescriptors:@[sort]]; self.items = appcastItems; } diff --git a/Sparkle/SUAppcastItem.h b/Sparkle/SUAppcastItem.h index b20ddb6e..453dd669 100644 --- a/Sparkle/SUAppcastItem.h +++ b/Sparkle/SUAppcastItem.h @@ -13,15 +13,15 @@ @property (copy, readonly) NSString *title; @property (copy, readonly) NSDate *date; @property (copy, readonly) NSString *itemDescription; -@property (retain, readonly) NSURL *releaseNotesURL; +@property (strong, readonly) NSURL *releaseNotesURL; @property (copy, readonly) NSString *DSASignature; @property (copy, readonly) NSString *minimumSystemVersion; @property (copy, readonly) NSString *maximumSystemVersion; -@property (retain, readonly) NSURL *fileURL; +@property (strong, readonly) NSURL *fileURL; @property (copy, readonly) NSString *versionString; @property (copy, readonly) NSString *displayVersionString; @property (copy, readonly) NSDictionary *deltaUpdates; -@property (retain, readonly) NSURL *infoURL; // UK 2007-08-31 +@property (strong, readonly) NSURL *infoURL; // UK 2007-08-31 // Initializes with data from a dictionary provided by the RSS class. - (instancetype)initWithDictionary:(NSDictionary *)dict; diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index f9baf9d0..2e20fc5b 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -18,15 +18,15 @@ @property (copy, readwrite) NSString *title; @property (copy, readwrite) NSDate *date; @property (copy, readwrite) NSString *itemDescription; -@property (retain, readwrite) NSURL *releaseNotesURL; +@property (strong, readwrite) NSURL *releaseNotesURL; @property (copy, readwrite) NSString *DSASignature; @property (copy, readwrite) NSString *minimumSystemVersion; @property (copy, readwrite) NSString *maximumSystemVersion; -@property (retain, readwrite) NSURL *fileURL; +@property (strong, readwrite) NSURL *fileURL; @property (copy, readwrite) NSString *versionString; @property (copy, readwrite) NSString *displayVersionString; @property (copy, readwrite) NSDictionary *deltaUpdates; -@property (retain, readwrite) NSURL *infoURL; +@property (strong, readwrite) NSURL *infoURL; @property (readwrite, copy) NSDictionary *propertiesDictionary; @end @@ -91,7 +91,6 @@ { if (error) *error = @"Feed item lacks sparkle:version attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)"; - [self release]; return nil; } @@ -115,7 +114,6 @@ { if (error) *error = @"No enclosure in feed item"; - [self release]; return nil; } @@ -125,7 +123,6 @@ if (error) { *error = @"Feed item's enclosure lacks URL"; } - [self release]; return nil; } @@ -168,10 +165,8 @@ [fakeAppCastDict removeObjectForKey:@"deltas"]; fakeAppCastDict[@"enclosure"] = deltaDictionary; SUAppcastItem *deltaItem = [[[self class] alloc] initWithDictionary:fakeAppCastDict]; - [fakeAppCastDict release]; deltas[deltaDictionary[@"sparkle:deltaFrom"]] = deltaItem; - [deltaItem release]; } self.deltaUpdates = deltas; } @@ -179,20 +174,4 @@ return self; } -- (void)dealloc -{ - self.title = nil; - self.date = nil; - self.itemDescription = nil; - self.releaseNotesURL = nil; - self.DSASignature = nil; - self.minimumSystemVersion = nil; - self.fileURL = nil; - self.versionString = nil; - self.displayVersionString = nil; - self.infoURL = nil; - self.propertiesDictionary = nil; - [super dealloc]; -} - @end diff --git a/Sparkle/SUAutomaticUpdateAlert.m b/Sparkle/SUAutomaticUpdateAlert.m index 6002b0a7..bf4dca32 100644 --- a/Sparkle/SUAutomaticUpdateAlert.m +++ b/Sparkle/SUAutomaticUpdateAlert.m @@ -11,9 +11,9 @@ #import "SUHost.h" @interface SUAutomaticUpdateAlert () -@property (retain) SUAppcastItem *updateItem; -@property (assign) id delegate; -@property (retain) SUHost *host; +@property (strong) SUAppcastItem *updateItem; +@property (weak) id delegate; +@property (strong) SUHost *host; @end @implementation SUAutomaticUpdateAlert @@ -35,13 +35,6 @@ return self; } -- (void)dealloc -{ - self.host = nil; - self.updateItem = nil; - [super dealloc]; -} - - (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; } - (IBAction)installNow:(id) __unused sender diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index dae7b521..175e01c3 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -67,7 +67,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 } else { - showUpdateAlertTimer = [[NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO] retain]; + showUpdateAlertTimer = [NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO]; // At this point the driver is idle, allow it to be interrupted for user-initiated update checks. isInterruptible = YES; @@ -92,7 +92,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)invalidateShowUpdateAlertTimer { [showUpdateAlertTimer invalidate]; - [showUpdateAlertTimer release]; showUpdateAlertTimer = nil; } @@ -100,8 +99,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 { [self stopUpdatingOnTermination]; [self invalidateShowUpdateAlertTimer]; - [alert release]; - [super dealloc]; } - (void)abortUpdate diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 96b92a8a..284074a6 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -42,8 +42,6 @@ } SUAppcast *appcast = [[SUAppcast alloc] init]; - CFRetain(appcast); // We'll manage the appcast's memory ourselves so we don't have to make it an IV to support GC. - [appcast release]; [appcast setDelegate:self]; [appcast setUserAgentString:[updater userAgentString]]; @@ -130,14 +128,13 @@ if (binaryDeltaSupported()) { SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[host version]]; if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) { - nonDeltaUpdateItem = [item retain]; + nonDeltaUpdateItem = item; item = deltaUpdateItem; } } } - updateItem = [item retain]; - if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast. + updateItem = item; if (updateItem == nil) { [self didNotFindUpdate]; return; } if ([self itemContainsValidUpdate:updateItem]) @@ -148,7 +145,6 @@ - (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error { - if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast. [self abortUpdateWithError:error]; } @@ -185,13 +181,11 @@ NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [host name], [updateItem versionString]]; - [tempDir release]; - tempDir = [[[host appSupportPath] stringByAppendingPathComponent:downloadFileName] retain]; + tempDir = [[host appSupportPath] stringByAppendingPathComponent:downloadFileName]; int cnt=1; while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999) { - [tempDir release]; - tempDir = [[[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain]; + tempDir = [[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]]; } // Create the temporary directory if necessary. @@ -203,7 +197,7 @@ [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.",tempDir]}]]; } - downloadPath = [[tempDir stringByAppendingPathComponent:name] retain]; + downloadPath = [tempDir stringByAppendingPathComponent:name]; [download setDestination:downloadPath allowOverwrite:YES]; } @@ -249,7 +243,6 @@ [self unarchiverDidFail:nil]; return; } - CFRetain(unarchiver); // Manage this memory manually so we don't have to make it an IV. [unarchiver setDelegate:self]; [unarchiver start]; } @@ -257,7 +250,6 @@ - (void)failedToApplyDeltaUpdate { // When a delta update fails to apply we fall back on updating via a full install. - [updateItem release]; updateItem = nonDeltaUpdateItem; nonDeltaUpdateItem = nil; @@ -266,14 +258,11 @@ - (void)unarchiverDidFinish:(SUUnarchiver *)ua { - if (ua) { CFRelease(ua); } [self installWithToolAndRelaunch:YES]; } - (void)unarchiverDidFail:(SUUnarchiver *)ua { - if (ua) { CFRelease(ua); } - if ([updateItem isDeltaUpdate]) { [self failedToApplyDeltaUpdate]; return; @@ -340,7 +329,7 @@ [[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] withIntermediateDirectories: YES attributes: @{} error: &error]; if( [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error] ) - relaunchPath = [targetPath retain]; + relaunchPath = targetPath; else [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]}]]; } @@ -394,7 +383,6 @@ - (void)abortUpdate { - [[self retain] autorelease]; // In case the notification center was the last one holding on to us. [self cleanUpDownload]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [super abortUpdate]; @@ -414,15 +402,4 @@ [self abortUpdate]; } -- (void)dealloc -{ - [updateItem release]; - [nonDeltaUpdateItem release]; - [download release]; - [downloadPath release]; - [tempDir release]; - [relaunchPath release]; - [super dealloc]; -} - @end diff --git a/Sparkle/SUBinaryDeltaTool.m b/Sparkle/SUBinaryDeltaTool.m index 0f71fbf0..d1632e66 100644 --- a/Sparkle/SUBinaryDeltaTool.m +++ b/Sparkle/SUBinaryDeltaTool.m @@ -26,9 +26,9 @@ extern int bsdiff(int argc, const char **argv); @interface CreateBinaryDeltaOperation : NSOperation @property (copy) NSString *relativePath; -@property (retain) NSString *resultPath; -@property (retain) NSString *_fromPath; -@property (retain) NSString *_toPath; +@property (strong) NSString *resultPath; +@property (strong) NSString *_fromPath; +@property (strong) NSString *_toPath; - (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree; @end @@ -57,16 +57,6 @@ extern int bsdiff(int argc, const char **argv); self.resultPath = temporaryFile; } -- (void)dealloc -{ - self.relativePath = nil; - self.resultPath = nil; - self._fromPath = nil; - self._toPath = nil; - - [super dealloc]; -} - @end static NSDictionary *infoForFile(FTSENT *ent) @@ -81,7 +71,7 @@ static NSDictionary *infoForFile(FTSENT *ent) static NSString *absolutePath(NSString *path) { - NSURL *url = [[[NSURL alloc] initFileURLWithPath:path] autorelease]; + NSURL *url = [[NSURL alloc] initFileURLWithPath:path]; return [[url absoluteURL] path]; } @@ -251,12 +241,10 @@ int main(int argc, char **argv) CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:oldPath newTree:newPath]; [deltaQueue addOperation:operation]; [deltaOperations addObject:operation]; - [operation release]; } } [deltaQueue waitUntilAllOperationsAreFinished]; - [deltaQueue release]; for (CreateBinaryDeltaOperation *operation in deltaOperations) { NSString *resultPath = [operation resultPath]; diff --git a/Sparkle/SUCodeSigningVerifier.m b/Sparkle/SUCodeSigningVerifier.m index 4256b8bb..2c74de55 100644 --- a/Sparkle/SUCodeSigningVerifier.m +++ b/Sparkle/SUCodeSigningVerifier.m @@ -19,6 +19,11 @@ SecRequirementRef requirement = NULL; SecStaticCodeRef staticCode = NULL; SecCodeRef hostCode = NULL; + NSBundle *newBundle; + CFErrorRef cfError = NULL; + if (error) { + *error = nil; + } result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode); if (result != 0) { @@ -32,20 +37,20 @@ goto finally; } - NSBundle *newBundle = [NSBundle bundleWithPath:destinationPath]; + newBundle = [NSBundle bundleWithPath:destinationPath]; if (!newBundle) { SULog(@"Failed to load NSBundle for update"); result = -1; goto finally; } - result = SecStaticCodeCreateWithPath((CFURLRef)[newBundle executableURL], kSecCSDefaultFlags, &staticCode); + result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle executableURL], kSecCSDefaultFlags, &staticCode); if (result != 0) { SULog(@"Failed to get static code %d", result); goto finally; } - result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, (CFErrorRef *)error); + result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, &cfError); if (result != 0 && error) { if (result == errSecCSReqFailed) { CFStringRef requirementString = nil; @@ -58,7 +63,7 @@ [self logSigningInfoForCode:staticCode label:@"new info"]; } - [*error autorelease]; + *error = CFBridgingRelease(cfError); } finally: @@ -72,7 +77,7 @@ finally: CFDictionaryRef signingInfo = nil; const SecCSFlags flags = kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation; if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) { - NSDictionary* signingDict = (NSDictionary*)signingInfo; + NSDictionary* signingDict = CFBridgingRelease(signingInfo); NSMutableDictionary* relevantInfo = [NSMutableDictionary dictionary]; for (NSString* key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) { relevantInfo[key] = signingDict[key]; @@ -80,7 +85,6 @@ finally: NSDictionary* infoPlist = signingDict[@"info-plist"]; relevantInfo[@"version"] = infoPlist[@"CFBundleShortVersionString"]; relevantInfo[@"build"] = infoPlist[@"CFBundleVersion"]; - CFRelease(signingInfo); SULog(@"%@: %@", label, relevantInfo); } } diff --git a/Sparkle/SUDSAVerifier.m b/Sparkle/SUDSAVerifier.m index f761d793..42d5170c 100644 --- a/Sparkle/SUDSAVerifier.m +++ b/Sparkle/SUDSAVerifier.m @@ -33,19 +33,19 @@ static NSData *rawKeyData( NSString *str ); BOOL result = NO; NSData *pathData = nil, *sigData = nil; CFDataRef hashData = NULL; - CSSM_KEY_PTR pubKey = cdsaCreateKey((CFDataRef)rawKeyData(pkeyString)); // Create the DSA key + CSSM_KEY_PTR pubKey = cdsaCreateKey((__bridge CFDataRef)rawKeyData(pkeyString)); // Create the DSA key CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE; if ( !pubKey ) return NO; if ( (cspHandle = cdsaInit()) == CSSM_INVALID_HANDLE ) goto validate_end; // Init CDSA if ( !cdsaVerifyKey(cspHandle, pubKey) ) goto validate_end; // Verify the key is valid if ( (pathData = [NSData dataWithContentsOfFile:path]) == nil ) goto validate_end; // File data - if ( (hashData = cdsaCreateSHA1Digest(cspHandle, (CFDataRef)pathData)) == NULL ) goto validate_end; // Hash + if ( (hashData = cdsaCreateSHA1Digest(cspHandle, (__bridge CFDataRef)pathData)) == NULL ) goto validate_end; // Hash // Remove any line feeds from end of signature // (Not likely needed, but the verify _can_ fail if there is, so...) if ( [encodedSignature characterAtIndex:[encodedSignature length] - 1] == '\n' ) { - NSMutableString *sig = [[encodedSignature mutableCopy] autorelease]; + NSMutableString *sig = [encodedSignature mutableCopy]; while ( [sig characterAtIndex:[sig length] - 1] == '\n' ) [sig deleteCharactersInRange:NSMakeRange([sig length] - 1, 1)]; encodedSignature = sig; @@ -53,7 +53,7 @@ static NSData *rawKeyData( NSString *str ); if ( (sigData = b64decode(encodedSignature)) == nil ) goto validate_end; // Decode signature // Verify the signature on the file - result = cdsaVerifySignature( cspHandle, pubKey, hashData, (CFDataRef)sigData ); + result = cdsaVerifySignature( cspHandle, pubKey, hashData, (__bridge CFDataRef)sigData ); validate_end: cdsaReleaseKey( pubKey ); @@ -126,7 +126,7 @@ static NSData *b64decode( NSString *str ) static NSData *rawKeyData( NSString *key ) { if ( (key == nil) || ([key length] == 0) ) return nil; - NSMutableString *t = [[key mutableCopy] autorelease]; + NSMutableString *t = [key mutableCopy]; // Remove the PEM guards (if present) [t replaceOccurrencesOfString:@"-" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])]; diff --git a/Sparkle/SUHost.h b/Sparkle/SUHost.h index 520b9f56..3d0d5683 100644 --- a/Sparkle/SUHost.h +++ b/Sparkle/SUHost.h @@ -16,7 +16,7 @@ NSString *defaultsDomain; BOOL usesStandardUserDefaults; } -@property (retain, readonly) NSBundle *bundle; +@property (strong, readonly) NSBundle *bundle; + (NSString *)systemVersionString; diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index d96d3447..8bb80bf6 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -24,7 +24,7 @@ typedef struct { #endif @interface SUHost () -@property (retain, readwrite) NSBundle *bundle; +@property (strong, readwrite) NSBundle *bundle; @end @implementation SUHost @@ -40,9 +40,9 @@ typedef struct { SULog(@"Sparkle Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", bundle); } - defaultsDomain = [[bundle objectForInfoDictionaryKey:SUDefaultsDomainKey] retain]; + defaultsDomain = [bundle objectForInfoDictionaryKey:SUDefaultsDomainKey]; if (!defaultsDomain) { - defaultsDomain = [[bundle bundleIdentifier] retain]; + defaultsDomain = [bundle bundleIdentifier]; } // If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y. @@ -51,12 +51,6 @@ typedef struct { return self; } -- (void)dealloc -{ - [defaultsDomain release]; - self.bundle = nil; - [super dealloc]; -} - (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self bundlePath], [self installationPath]]; } @@ -134,7 +128,7 @@ typedef struct { if (!iconPath) { iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType: nil]; } - NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease]; + NSImage *icon = [[NSImage alloc] initWithContentsOfFile:iconPath]; // Use a default icon if none is defined. if (!icon) { BOOL isMainBundle = (bundle == [NSBundle mainBundle]); @@ -198,7 +192,7 @@ typedef struct { return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName]; } - CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain); + CFPropertyListRef obj = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)defaultsDomain); return CFBridgingRelease(obj); } @@ -210,8 +204,8 @@ typedef struct { } else { - CFPreferencesSetValue((CFStringRef)defaultName, value, (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFPropertyListRef)(value), (__bridge CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFPreferencesSynchronize((__bridge CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); } } @@ -222,7 +216,7 @@ typedef struct { } BOOL value; - CFPropertyListRef plr = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain); + CFPropertyListRef plr = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)defaultsDomain); if (plr == NULL) { value = NO; } @@ -242,8 +236,8 @@ typedef struct { } else { - CFPreferencesSetValue((CFStringRef)defaultName, (CFBooleanRef)@(value), (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFBooleanRef)@(value), (__bridge CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFPreferencesSynchronize((__bridge CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); } } diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index bc4f549b..fe1b1ffa 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -53,8 +53,7 @@ static NSString* sUpdateFolder = nil; NSString *fallbackPackagePath = nil; NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath: inUpdateFolder]; - [sUpdateFolder release]; - sUpdateFolder = [inUpdateFolder retain]; + sUpdateFolder = inUpdateFolder; while ((currentFile = [dirEnum nextObject])) { @@ -138,7 +137,7 @@ static NSString* sUpdateFolder = nil; SULog( @"mdimporting" ); - NSTask *mdimport = [[[NSTask alloc] init] autorelease]; + NSTask *mdimport = [[NSTask alloc] init]; [mdimport setLaunchPath:@"/usr/bin/mdimport"]; [mdimport setArguments:@[installationPath]]; @try diff --git a/Sparkle/SULog.m b/Sparkle/SULog.m index b58235aa..c77cfd38 100644 --- a/Sparkle/SULog.m +++ b/Sparkle/SULog.m @@ -60,7 +60,7 @@ void SULog( NSString* format, ... ) { va_list ap; va_start(ap, format); - NSString* theStr = [[[NSString alloc] initWithFormat: format arguments: ap] autorelease]; + NSString* theStr = [[NSString alloc] initWithFormat: format arguments: ap]; FILE* logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation],"a"); if( !logfile ) NSLog( @"%@",theStr ); diff --git a/Sparkle/SUPlainInstallerInternals.m b/Sparkle/SUPlainInstallerInternals.m index 51d83d00..4c7cce32 100644 --- a/Sparkle/SUPlainInstallerInternals.m +++ b/Sparkle/SUPlainInstallerInternals.m @@ -485,7 +485,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (err == noErr && hadFileAtDest) { - NSFileManager *manager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *manager = [[NSFileManager alloc] init]; BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error]; if (!success && hadFileAtDest) { @@ -498,7 +498,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL); if (err == noErr) { - NSFileManager *manager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *manager = [[NSFileManager alloc] init]; BOOL success = [manager copyItemAtPath:src toPath:dst error:error]; if (!success) { diff --git a/Sparkle/SUStandardVersionComparator.m b/Sparkle/SUStandardVersionComparator.m index 319fd11e..1a82ee3d 100644 --- a/Sparkle/SUStandardVersionComparator.m +++ b/Sparkle/SUStandardVersionComparator.m @@ -56,7 +56,7 @@ typedef enum { // Nothing to do here return parts; } - s = [[[version substringToIndex:1] mutableCopy] autorelease]; + s = [[version substringToIndex:1] mutableCopy]; oldType = [self typeOfCharacter:s]; n = [version length] - 1; for (i = 1; i <= n; ++i) { @@ -64,7 +64,7 @@ typedef enum { newType = [self typeOfCharacter:character]; if (oldType != newType || oldType == kSeparatorType) { // We've reached a new segment - NSString *aPart = [[[NSString alloc] initWithString:s] autorelease]; + NSString *aPart = [[NSString alloc] initWithString:s]; [parts addObject:aPart]; [s setString:character]; } else { diff --git a/Sparkle/SUStatusController.h b/Sparkle/SUStatusController.h index aa1d7d81..af17c3c6 100644 --- a/Sparkle/SUStatusController.h +++ b/Sparkle/SUStatusController.h @@ -13,8 +13,8 @@ @class SUHost; @interface SUStatusController : SUWindowController -@property (assign) IBOutlet NSButton *actionButton; -@property (assign) IBOutlet NSProgressIndicator* progressBar; +@property (weak) IBOutlet NSButton *actionButton; +@property (weak) IBOutlet NSProgressIndicator* progressBar; @property (copy) NSString *statusText; @property double progressValue; diff --git a/Sparkle/SUStatusController.m b/Sparkle/SUStatusController.m index b0376a6e..77278c2b 100644 --- a/Sparkle/SUStatusController.m +++ b/Sparkle/SUStatusController.m @@ -16,7 +16,7 @@ @interface SUStatusController () @property (copy) NSString *title, *buttonTitle; -@property (retain) SUHost *host; +@property (strong) SUHost *host; @end @implementation SUStatusController @@ -40,15 +40,6 @@ return self; } -- (void)dealloc -{ - self.host = nil; - self.title = nil; - self.statusText = nil; - self.buttonTitle = nil; - [super dealloc]; -} - - (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; } - (void)awakeFromNib diff --git a/Sparkle/SUSystemProfiler.m b/Sparkle/SUSystemProfiler.m index f417d507..091e5c8b 100644 --- a/Sparkle/SUSystemProfiler.m +++ b/Sparkle/SUSystemProfiler.m @@ -25,7 +25,7 @@ - (NSDictionary *)modelTranslationTable { NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUModelTranslation" ofType:@"plist"]; - return [[[NSDictionary alloc] initWithContentsOfFile:path] autorelease]; + return [[NSDictionary alloc] initWithContentsOfFile:path]; } - (NSMutableArray *)systemProfileArrayForHost:(SUHost *)host diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index f5464290..0d55a950 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -70,7 +70,7 @@ - (void)updateAlert:(SUUpdateAlert *) __unused alert finishedWithChoice:(SUUpdateAlertChoice)choice { - [updateAlert release]; updateAlert = nil; + updateAlert = nil; [host setObject:nil forUserDefaultsKey:SUSkippedVersionKey]; switch (choice) { @@ -186,7 +186,6 @@ if (statusController) { [statusController close]; - [statusController autorelease]; statusController = nil; } } @@ -203,7 +202,6 @@ if (statusController) { [statusController close]; - [statusController autorelease]; statusController = nil; } [super abortUpdate]; diff --git a/Sparkle/SUUnarchiver.h b/Sparkle/SUUnarchiver.h index bb248168..9afeb215 100644 --- a/Sparkle/SUUnarchiver.h +++ b/Sparkle/SUUnarchiver.h @@ -13,11 +13,11 @@ @protocol SUUnarchiverDelegate; @interface SUUnarchiver : NSObject { - id delegate; + id __weak delegate; NSString *archivePath; SUHost *updateHost; } -@property (assign) id delegate; +@property (weak) id delegate; + (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host; diff --git a/Sparkle/SUUnarchiver.m b/Sparkle/SUUnarchiver.m index 907b82a1..59a764e4 100644 --- a/Sparkle/SUUnarchiver.m +++ b/Sparkle/SUUnarchiver.m @@ -23,7 +23,7 @@ for (id current in [self unarchiverImplementations]) { if ([current canUnarchivePath:path]) { - return [[[current alloc] initWithPath:path host:host] autorelease]; + return [[current alloc] initWithPath:path host:host]; } } return nil; diff --git a/Sparkle/SUUnarchiver_Private.m b/Sparkle/SUUnarchiver_Private.m index cbbbc7eb..d594da9b 100644 --- a/Sparkle/SUUnarchiver_Private.m +++ b/Sparkle/SUUnarchiver_Private.m @@ -16,18 +16,11 @@ if ((self = [super init])) { archivePath = [path copy]; - updateHost = [host retain]; + updateHost = host; } return self; } -- (void)dealloc -{ - [archivePath release]; - [updateHost release]; - [super dealloc]; -} - + (BOOL)canUnarchivePath:(NSString *) __unused path { return NO; diff --git a/Sparkle/SUUpdateAlert.h b/Sparkle/SUUpdateAlert.h index 7ceabc51..984c1b2d 100644 --- a/Sparkle/SUUpdateAlert.h +++ b/Sparkle/SUUpdateAlert.h @@ -35,8 +35,8 @@ typedef enum NSProgressIndicator *releaseNotesSpinner; BOOL webViewFinishedLoading; } -@property (assign) id delegate; -@property (assign) id versionDisplayer; +@property (weak) id delegate; +@property (weak) id versionDisplayer; - (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host; diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index fd4549d7..c981920b 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -34,8 +34,8 @@ self = [super initWithHost:host windowNibName:@"SUUpdateAlert"]; if (self) { - host = [aHost retain]; - updateItem = [item retain]; + host = aHost; + updateItem = item; [self setShouldCascadeWindows:NO]; // Alex: This dummy line makes sure that the binary is linked against WebKit. @@ -48,12 +48,6 @@ - (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [host bundlePath]]; } -- (void)dealloc -{ - [updateItem release]; - [host release]; - [super dealloc]; -} - (void)endWithSelection:(SUUpdateAlertChoice)choice { @@ -103,7 +97,7 @@ // Stick a nice big spinner in the middle of the web view until the page is loaded. NSRect frame = [[releaseNotesView superview] frame]; - releaseNotesSpinner = [[[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame)-16, NSMidY(frame)-16, 32, 32)] autorelease]; + releaseNotesSpinner = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame)-16, NSMidY(frame)-16, 32, 32)]; [releaseNotesSpinner setStyle:NSProgressIndicatorSpinningStyle]; [releaseNotesSpinner startAnimation:self]; webViewFinishedLoading = NO; @@ -326,7 +320,7 @@ // Clean up the contextual menu. - (NSArray *)webView:(WebView *) __unused sender contextMenuItemsForElement:(NSDictionary *) __unused element defaultMenuItems:(NSArray *)defaultMenuItems { - NSMutableArray *webViewMenuItems = [[defaultMenuItems mutableCopy] autorelease]; + NSMutableArray *webViewMenuItems = [defaultMenuItems mutableCopy]; if (webViewMenuItems) { diff --git a/Sparkle/SUUpdateDriver.h b/Sparkle/SUUpdateDriver.h index dbea2ca3..63406962 100644 --- a/Sparkle/SUUpdateDriver.h +++ b/Sparkle/SUUpdateDriver.h @@ -23,7 +23,7 @@ extern NSString * const SUUpdateDriverFinishedNotification; BOOL finished; BOOL isInterruptible; } -@property (retain) SUHost *host; +@property (strong) SUHost *host; - (instancetype) initWithUpdater:(SUUpdater *)updater; - (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host; diff --git a/Sparkle/SUUpdateDriver.m b/Sparkle/SUUpdateDriver.m index f63503a4..d9aacd03 100644 --- a/Sparkle/SUUpdateDriver.m +++ b/Sparkle/SUUpdateDriver.m @@ -29,7 +29,7 @@ NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished"; - (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)h { appcastURL = [URL copy]; - host = [h retain]; + host = h; } - (void)abortUpdate @@ -38,11 +38,4 @@ NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished"; [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self]; } -- (void)dealloc -{ - self.host = nil; - [appcastURL release]; - [super dealloc]; -} - @end diff --git a/Sparkle/SUUpdatePermissionPrompt.m b/Sparkle/SUUpdatePermissionPrompt.m index 631ef223..93d9e462 100644 --- a/Sparkle/SUUpdatePermissionPrompt.m +++ b/Sparkle/SUUpdatePermissionPrompt.m @@ -29,11 +29,11 @@ self = [super initWithHost:aHost windowNibName:@"SUUpdatePermissionPrompt"]; if (self) { - host = [aHost retain]; + host = aHost; delegate = d; self.isShowingMoreInfo = NO; self.shouldSendProfile = [self shouldAskAboutProfile]; - systemProfileInformationArray = [profile retain]; + systemProfileInformationArray = profile; [self setShouldCascadeWindows:NO]; } return self; @@ -45,8 +45,8 @@ // to the user's attention. Otherwise the prompt would be hidden behind other applications and // the user would not know why the application was paused. if ([aHost isBackgroundApplication]) { [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; } - - SUUpdatePermissionPrompt *prompt = [[[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d] autorelease]; + + SUUpdatePermissionPrompt *prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d]; [NSApp runModalForWindow:[prompt window]]; } @@ -67,12 +67,6 @@ - (BOOL)tableView:(NSTableView *) __unused tableView shouldSelectRow:(NSInteger) __unused row { return NO; } -- (void)dealloc -{ - [host release]; - [systemProfileInformationArray release]; - [super dealloc]; -} - (NSImage *)icon { diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index 235e4b84..4d62d603 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -29,7 +29,7 @@ SUHost *host; } -@property (assign) IBOutlet id delegate; +@property (weak) IBOutlet id delegate; + (SUUpdater *)sharedUpdater; + (SUUpdater *)updaterForBundle:(NSBundle *)bundle; diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index b3f5a9d9..f321bd12 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -28,7 +28,7 @@ NSString *const SUUpdaterAppcastItemNotificationKey = @"SUUpdaterAppcastItemNoti NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotificationKey"; @interface SUUpdater () -@property (retain) NSTimer *checkTimer; +@property (strong) NSTimer *checkTimer; - (instancetype)initForBundle:(NSBundle *)bundle; - (void)startUpdateCycle; - (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver; @@ -64,7 +64,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault if (bundle == nil) bundle = [NSBundle mainBundle]; id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]]; if (updater == nil) { - updater = [[[[self class] alloc] initForBundle:bundle] autorelease]; + updater = [[[self class] alloc] initForBundle:bundle]; } return updater; } @@ -83,8 +83,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]]; if (updater) { - [self release]; - self = [updater retain]; + self = updater; } else if (self) { @@ -199,7 +198,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault { if ([note object] == driver && [driver finished]) { - [driver release]; driver = nil; + driver = nil; [self scheduleNextUpdateCheck]; } } @@ -298,7 +297,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault // Background update checks should only happen if we have a network connection. // Wouldn't want to annoy users on dial-up by establishing a connection every // hour or so: - SUUpdateDriver * theUpdateDriver = [[[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class]) alloc] initWithUpdater:self] autorelease]; + SUUpdateDriver * theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class]) alloc] initWithUpdater:self]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self checkForUpdatesInBgReachabilityCheckWithDriver:theUpdateDriver]; @@ -317,12 +316,12 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault [driver abortUpdate]; } - [self checkForUpdatesWithDriver:[[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self] autorelease]]; + [self checkForUpdatesWithDriver:[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self]]; } - (void)checkForUpdateInformation { - [self checkForUpdatesWithDriver:[[[SUProbingUpdateDriver alloc] initWithUpdater:self] autorelease]]; + [self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithUpdater:self]]; } - (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d @@ -343,7 +342,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault return; } - driver = [d retain]; + driver = d; // If we're not given a driver at all, just schedule the next update check and bail. if (!driver) @@ -362,8 +361,8 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (void)registerAsObserver { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil]; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:(NSKeyValueObservingOptions)0 context:SUUpdaterDefaultsObservationContext]; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:(NSKeyValueObservingOptions)0 context:SUUpdaterDefaultsObservationContext]; + [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:(NSKeyValueObservingOptions)0 context:(__bridge void *)(SUUpdaterDefaultsObservationContext)]; + [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:(NSKeyValueObservingOptions)0 context:(__bridge void *)(SUUpdaterDefaultsObservationContext)]; } - (void)unregisterAsObserver @@ -382,7 +381,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (context == SUUpdaterDefaultsObservationContext) + if (context == (__bridge void *)(SUUpdaterDefaultsObservationContext)) { // Allow a small delay, because perhaps the user or developer wants to change both preferences. This allows the developer to interpret a zero check interval as a sign to disable automatic checking. // Or we may get this from the developer and from our own KVO observation, this will effectively coalesce them. @@ -475,7 +474,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault NSString *version = [SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"]; NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [host name], [host displayVersion], version ? version : @"?"]; NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; - return [[[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding] autorelease]; + return [[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding]; } - (void)setSendsSystemProfile:(BOOL)sendsSystemProfile @@ -555,9 +554,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (void)dealloc { [self unregisterAsObserver]; - [host release]; - if (checkTimer) { [checkTimer invalidate]; self.checkTimer = nil; } // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it. - [super dealloc]; + if (checkTimer) { [checkTimer invalidate]; } // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it. } - (BOOL)validateMenuItem:(NSMenuItem *)item diff --git a/Sparkle/SUUserInitiatedUpdateDriver.m b/Sparkle/SUUserInitiatedUpdateDriver.m index 34c2733b..5916d24b 100644 --- a/Sparkle/SUUserInitiatedUpdateDriver.m +++ b/Sparkle/SUUserInitiatedUpdateDriver.m @@ -18,7 +18,6 @@ if (checkingController) { [[checkingController window] close]; - [checkingController release]; checkingController = nil; } } diff --git a/Tests/SUUpdaterTest.m b/Tests/SUUpdaterTest.m index c93dc334..df622620 100644 --- a/Tests/SUUpdaterTest.m +++ b/Tests/SUUpdaterTest.m @@ -11,7 +11,8 @@ #import "SUUpdater.h" @interface SUUpdaterTest : XCTestCase - +@property (strong) NSOperationQueue *queue; +@property (strong) SUUpdater *updater; @end @implementation SUUpdaterTest @@ -19,21 +20,21 @@ NSOperationQueue *queue; SUUpdater *updater; } +@synthesize queue; +@synthesize updater; - (void)setUp { [super setUp]; - queue = [[NSOperationQueue alloc] init]; - updater = [[SUUpdater alloc] init]; + self.queue = [[NSOperationQueue alloc] init]; + self.updater = [[SUUpdater alloc] init]; updater.delegate = self; } - (void)tearDown { - [updater release]; - updater = nil; - [queue release]; - queue = nil; + self.updater = nil; + self.queue = nil; [super tearDown]; } diff --git a/Vendor/CocoatechCore/NTSynchronousTask.h b/Vendor/CocoatechCore/NTSynchronousTask.h index 01d659fb..cbcbf2c8 100644 --- a/Vendor/CocoatechCore/NTSynchronousTask.h +++ b/Vendor/CocoatechCore/NTSynchronousTask.h @@ -10,7 +10,7 @@ #define NTSYNCHRONOUSTASK_H @interface NTSynchronousTask : NSObject -@property (readonly, retain) NSData *output; +@property (readonly, strong) NSData *output; @property (readonly) int result; // pass nil for directory if not needed diff --git a/Vendor/CocoatechCore/NTSynchronousTask.m b/Vendor/CocoatechCore/NTSynchronousTask.m index 7ac9946f..2ee1ce8c 100644 --- a/Vendor/CocoatechCore/NTSynchronousTask.m +++ b/Vendor/CocoatechCore/NTSynchronousTask.m @@ -14,10 +14,10 @@ #import "NTSynchronousTask.h" @interface NTSynchronousTask () -@property (retain) NSTask *task; -@property (retain) NSPipe *outputPipe; -@property (retain) NSPipe *inputPipe; -@property (readwrite, retain) NSData *output; +@property (strong) NSTask *task; +@property (strong) NSPipe *outputPipe; +@property (strong) NSPipe *inputPipe; +@property (readwrite, strong) NSData *output; @property (getter = isDone) BOOL done; @property (readwrite) int result; @end @@ -47,9 +47,9 @@ self = [super init]; if (self) { - self.task = [[[NSTask alloc] init] autorelease]; - self.outputPipe = [[[NSPipe alloc] init] autorelease]; - self.inputPipe = [[[NSPipe alloc] init] autorelease]; + self.task = [[NSTask alloc] init]; + self.outputPipe = [[NSPipe alloc] init]; + self.inputPipe = [[NSPipe alloc] init]; self.task.standardInput = self.inputPipe; self.task.standardOutput = self.outputPipe; @@ -65,13 +65,6 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - - self.task = nil; - self.outputPipe = nil; - self.inputPipe = nil; - self.output = nil; - - [super dealloc]; } - (void)run:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input @@ -132,34 +125,30 @@ + (NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input { - NSData* result = nil; - // we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased @autoreleasepool { + NSData* result = nil; + // we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased @try { NTSynchronousTask* task = [[NTSynchronousTask alloc] init]; [task run:toolPath directory:currentDirectory withArgs:args input:input]; if ([task result] == 0) { - result = [[task output] retain]; + result = [task output]; } - - [task release]; } @catch (NSException *) { } - + + return result; } - - // retained above - return [result autorelease]; } +(int) task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input output: (NSData**)outData { - int taskResult = 0; // we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased @autoreleasepool { + int taskResult = 0; if (outData) { *outData = nil; } @@ -171,21 +160,15 @@ taskResult = [task result]; if (outData) { - *outData = [[task output] retain]; + *outData = [task output]; } - - [task release]; + } @catch (NSException *) { taskResult = errCppGeneral; } - + + return taskResult; } - // retained above - if (outData) { - [*outData autorelease]; - } - - return taskResult; } @end