From 93e339f32e3d4ea5b80acbab03acd6d9879504ef Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Fri, 20 Jun 2014 13:26:39 -0600 Subject: [PATCH 1/3] Convert Sparkle to ARC, take three. --- Configurations/ConfigCommon.xcconfig | 1 + Configurations/ConfigTestApp.xcconfig | 1 + NTSynchronousTask.h | 2 +- NTSynchronousTask.m | 45 +++++++++------------------ SUAppcast.h | 4 +-- SUAppcast.m | 20 +++--------- SUAppcastItem.h | 6 ++-- SUAppcastItem.m | 27 ++-------------- SUAutomaticUpdateAlert.m | 13 ++------ SUAutomaticUpdateDriver.m | 5 +-- SUBasicUpdateDriver.m | 35 ++++----------------- SUBinaryDeltaTool.m | 26 +++------------- SUCodeSigningVerifier.m | 15 ++++++--- SUDSAVerifier.m | 10 +++--- SUHost.h | 2 +- SUHost.m | 26 ++++++---------- SUInstaller.m | 5 ++- SULog.m | 2 +- SUPlainInstaller.m | 2 +- SUPlainInstallerInternals.m | 4 +-- SUStandardVersionComparator.m | 4 +-- SUStatusController.h | 4 +-- SUStatusController.m | 11 +------ SUSystemProfiler.m | 2 +- SUUIBasedUpdateDriver.m | 4 +-- SUUnarchiver.h | 4 +-- SUUnarchiver.m | 2 +- SUUnarchiver_Private.m | 10 ++---- SUUpdateAlert.h | 4 +-- SUUpdateAlert.m | 14 +++------ SUUpdateDriver.h | 2 +- SUUpdateDriver.m | 9 +----- SUUpdatePermissionPrompt.m | 12 ++----- SUUpdater.h | 2 +- SUUpdater.m | 29 ++++++++--------- SUUserInitiatedUpdateDriver.m | 1 - Sparkle.xcodeproj/project.pbxproj | 4 +-- finish_installation.m | 30 +++++------------- 38 files changed, 123 insertions(+), 276 deletions(-) diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index f13835c0..8f479c68 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -8,6 +8,7 @@ GCC_PREFIX_HEADER = $(SDKROOT)/System/Library/Frameworks/Cocoa.framework/Headers ARCHS = x86_64 GCC_PREPROCESSOR_DEFINITIONS = FINISH_INSTALL_TOOL_NAME=$(FINISH_INSTALL_TOOL_NAME) +CLANG_ENABLE_OBJC_ARC = YES // Enable warnings GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES diff --git a/Configurations/ConfigTestApp.xcconfig b/Configurations/ConfigTestApp.xcconfig index 36540ca4..c7b03bcc 100644 --- a/Configurations/ConfigTestApp.xcconfig +++ b/Configurations/ConfigTestApp.xcconfig @@ -3,3 +3,4 @@ INFOPLIST_FILE = Test Application/Test Application-Info.plist PRODUCT_NAME = Sparkle Test App WRAPPER_EXTENSION = app +CLANG_ENABLE_OBJC_ARC = NO diff --git a/NTSynchronousTask.h b/NTSynchronousTask.h index 01d659fb..cbcbf2c8 100644 --- a/NTSynchronousTask.h +++ b/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/NTSynchronousTask.m b/NTSynchronousTask.m index 22b238e3..9f096a62 100644 --- a/NTSynchronousTask.m +++ b/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 *localException) { } + 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 *localException) { taskResult = errCppGeneral; } + return taskResult; } - // retained above - if (outData) { - [*outData autorelease]; - } - - return taskResult; } @end diff --git a/SUAppcast.h b/SUAppcast.h index 7f835dd0..d2236759 100644 --- a/SUAppcast.h +++ b/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/SUAppcast.m b/SUAppcast.m index d6e18a04..a60919b4 100644 --- a/SUAppcast.m +++ b/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 *)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/SUAppcastItem.h b/SUAppcastItem.h index b20ddb6e..453dd669 100644 --- a/SUAppcastItem.h +++ b/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/SUAppcastItem.m b/SUAppcastItem.m index c21a100d..136fdf7b 100644 --- a/SUAppcastItem.m +++ b/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/SUAutomaticUpdateAlert.m b/SUAutomaticUpdateAlert.m index 36da1ec6..c1a3916f 100644 --- a/SUAutomaticUpdateAlert.m +++ b/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)sender diff --git a/SUAutomaticUpdateDriver.m b/SUAutomaticUpdateDriver.m index 14c39bae..df647f07 100644 --- a/SUAutomaticUpdateDriver.m +++ b/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/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index cad0aac5..fb11eed1 100644 --- a/SUBasicUpdateDriver.m +++ b/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]; } @@ -183,13 +179,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. @@ -201,7 +195,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]; } @@ -247,7 +241,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]; } @@ -255,7 +248,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; @@ -264,14 +256,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; @@ -336,7 +325,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] : @"")]}]]; } @@ -390,7 +379,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]; @@ -410,15 +398,4 @@ [self abortUpdate]; } -- (void)dealloc -{ - [updateItem release]; - [nonDeltaUpdateItem release]; - [download release]; - [downloadPath release]; - [tempDir release]; - [relaunchPath release]; - [super dealloc]; -} - @end diff --git a/SUBinaryDeltaTool.m b/SUBinaryDeltaTool.m index 94e8e5db..ca3c40e8 100644 --- a/SUBinaryDeltaTool.m +++ b/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 @@ -55,16 +55,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) @@ -79,7 +69,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]; } @@ -131,8 +121,6 @@ int main(int argc, char **argv) exit(1); } - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *command = [NSString stringWithUTF8String:argv[1]]; NSString *oldPath = stringWithFileSystemRepresentation(argv[2]); NSString *newPath = stringWithFileSystemRepresentation(argv[3]); @@ -140,11 +128,9 @@ int main(int argc, char **argv) if ([command isEqualToString:@"apply"]) { int result = applyBinaryDelta(oldPath, newPath, patchFile); - [pool drain]; return result; } if (![command isEqualToString:@"create"]) { - [pool drain]; goto usage; } @@ -153,7 +139,6 @@ int main(int argc, char **argv) const char *sourcePaths[] = {[oldPath fileSystemRepresentation], 0}; FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles); if (!fts) { - [pool drain]; perror("fts_open"); return 1; } @@ -187,7 +172,6 @@ int main(int argc, char **argv) sourcePaths[0] = [newPath fileSystemRepresentation]; fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles); if (!fts) { - [pool drain]; perror("fts_open"); return 1; } @@ -251,12 +235,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/SUCodeSigningVerifier.m b/SUCodeSigningVerifier.m index 67d3884c..f20ef43e 100644 --- a/SUCodeSigningVerifier.m +++ b/SUCodeSigningVerifier.m @@ -19,7 +19,12 @@ 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) { SULog(@"Failed to copy host code %d", result); @@ -32,21 +37,21 @@ 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); - if (result != 0 && error) [*error autorelease]; + result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, &cfError); + if (result != 0 && error) CFBridgingRelease(cfError); finally: if (hostCode) CFRelease(hostCode); diff --git a/SUDSAVerifier.m b/SUDSAVerifier.m index e7a65cfa..9044b85e 100644 --- a/SUDSAVerifier.m +++ b/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/SUHost.h b/SUHost.h index 520b9f56..3d0d5683 100644 --- a/SUHost.h +++ b/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/SUHost.m b/SUHost.m index cf7a016a..e9a32d36 100644 --- a/SUHost.m +++ b/SUHost.m @@ -13,7 +13,7 @@ #import "SULog.h" @interface SUHost () -@property (retain, readwrite) NSBundle *bundle; +@property (strong, readwrite) NSBundle *bundle; @end @implementation SUHost @@ -29,9 +29,9 @@ 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. @@ -40,12 +40,6 @@ return self; } -- (void)dealloc -{ - [defaultsDomain release]; - self.bundle = nil; - [super dealloc]; -} - (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self bundlePath], [self installationPath]]; } @@ -123,7 +117,7 @@ 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]); @@ -183,7 +177,7 @@ return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName]; } - CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain); + CFPropertyListRef obj = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)defaultsDomain); return CFBridgingRelease(obj); } @@ -195,8 +189,8 @@ } 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); } } @@ -207,7 +201,7 @@ } BOOL value; - CFPropertyListRef plr = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain); + CFPropertyListRef plr = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)defaultsDomain); if (plr == NULL) { value = NO; } @@ -227,8 +221,8 @@ } 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/SUInstaller.m b/SUInstaller.m index 3fa3287b..4629130c 100644 --- a/SUInstaller.m +++ b/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/SULog.m b/SULog.m index b58235aa..c77cfd38 100644 --- a/SULog.m +++ b/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/SUPlainInstaller.m b/SUPlainInstaller.m index dac28c39..33223fe5 100644 --- a/SUPlainInstaller.m +++ b/SUPlainInstaller.m @@ -47,7 +47,7 @@ static NSString * const SUInstallerInstallationPathKey = @"SUInstallerInstallati if( haveOld && differentFromNew ) [self _movePathToTrash: oldPath]; // On success, trash old copy if there's still one due to renaming. } - NSMutableDictionary *mutableInfo = [[info mutableCopy] autorelease]; + NSMutableDictionary *mutableInfo = [info mutableCopy]; mutableInfo[SUInstallerResultKey] = @(result); mutableInfo[SUInstallerInstallationPathKey] = installationPath; if (!result && error) diff --git a/SUPlainInstallerInternals.m b/SUPlainInstallerInternals.m index 45267793..5ad0dc1d 100644 --- a/SUPlainInstallerInternals.m +++ b/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/SUStandardVersionComparator.m b/SUStandardVersionComparator.m index 6818c447..28b98526 100644 --- a/SUStandardVersionComparator.m +++ b/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/SUStatusController.h b/SUStatusController.h index aa1d7d81..af17c3c6 100644 --- a/SUStatusController.h +++ b/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/SUStatusController.m b/SUStatusController.m index 0eecff39..1c795f51 100644 --- a/SUStatusController.m +++ b/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/SUSystemProfiler.m b/SUSystemProfiler.m index a7b82354..7e658250 100644 --- a/SUSystemProfiler.m +++ b/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/SUUIBasedUpdateDriver.m b/SUUIBasedUpdateDriver.m index b22f6e88..11d4a027 100644 --- a/SUUIBasedUpdateDriver.m +++ b/SUUIBasedUpdateDriver.m @@ -66,7 +66,7 @@ - (void)updateAlert:(SUUpdateAlert *)alert finishedWithChoice:(SUUpdateAlertChoice)choice { - [updateAlert release]; updateAlert = nil; + updateAlert = nil; [host setObject:nil forUserDefaultsKey:SUSkippedVersionKey]; switch (choice) { @@ -182,7 +182,6 @@ if (statusController) { [statusController close]; - [statusController autorelease]; statusController = nil; } } @@ -199,7 +198,6 @@ if (statusController) { [statusController close]; - [statusController autorelease]; statusController = nil; } [super abortUpdate]; diff --git a/SUUnarchiver.h b/SUUnarchiver.h index bb248168..9afeb215 100644 --- a/SUUnarchiver.h +++ b/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/SUUnarchiver.m b/SUUnarchiver.m index 907b82a1..59a764e4 100644 --- a/SUUnarchiver.m +++ b/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/SUUnarchiver_Private.m b/SUUnarchiver_Private.m index d97c01f2..56e655db 100644 --- a/SUUnarchiver_Private.m +++ b/SUUnarchiver_Private.m @@ -7,6 +7,7 @@ // #import "SUUnarchiver_Private.h" +#import "SUHost.h" @implementation SUUnarchiver (Private) @@ -15,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 *)path { return NO; diff --git a/SUUpdateAlert.h b/SUUpdateAlert.h index 17650b8e..05a5f777 100644 --- a/SUUpdateAlert.h +++ b/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/SUUpdateAlert.m b/SUUpdateAlert.m index 7d33431e..274e12cc 100644 --- a/SUUpdateAlert.m +++ b/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 *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems { - NSMutableArray *webViewMenuItems = [[defaultMenuItems mutableCopy] autorelease]; + NSMutableArray *webViewMenuItems = [defaultMenuItems mutableCopy]; if (webViewMenuItems) { diff --git a/SUUpdateDriver.h b/SUUpdateDriver.h index 67371ec2..1129baa7 100644 --- a/SUUpdateDriver.h +++ b/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/SUUpdateDriver.m b/SUUpdateDriver.m index f63503a4..d9aacd03 100644 --- a/SUUpdateDriver.m +++ b/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/SUUpdatePermissionPrompt.m b/SUUpdatePermissionPrompt.m index ae25a228..d9a85c84 100644 --- a/SUUpdatePermissionPrompt.m +++ b/SUUpdatePermissionPrompt.m @@ -27,11 +27,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; @@ -44,7 +44,7 @@ // the user would not know why the application was paused. if ([aHost isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; } - id prompt = [[[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d] autorelease]; + id prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d]; [NSApp runModalForWindow:[prompt window]]; } @@ -65,12 +65,6 @@ - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row { return NO; } -- (void)dealloc -{ - [host release]; - [systemProfileInformationArray release]; - [super dealloc]; -} - (NSImage *)icon { diff --git a/SUUpdater.h b/SUUpdater.h index 90bda895..f5e6048d 100644 --- a/SUUpdater.h +++ b/SUUpdater.h @@ -21,7 +21,7 @@ SUHost *host; } -@property (assign) IBOutlet id delegate; +@property (weak) IBOutlet id delegate; + (SUUpdater *)sharedUpdater; + (SUUpdater *)updaterForBundle:(NSBundle *)bundle; diff --git a/SUUpdater.m b/SUUpdater.m index 7ccca4c8..ee9d80e3 100644 --- a/SUUpdater.m +++ b/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) { @@ -200,7 +199,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault { if ([note object] == driver && [driver finished]) { - [driver release]; driver = nil; + driver = nil; [self scheduleNextUpdateCheck]; } } @@ -299,7 +298,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(0, 0), ^{ [self checkForUpdatesInBgReachabilityCheckWithDriver:theUpdateDriver]; @@ -318,12 +317,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 @@ -344,7 +343,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) @@ -363,8 +362,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:0 context:SUUpdaterDefaultsObservationContext]; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:0 context:SUUpdaterDefaultsObservationContext]; + [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:0 context:(__bridge void *)(SUUpdaterDefaultsObservationContext)]; + [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:0 context:(__bridge void *)(SUUpdaterDefaultsObservationContext)]; } - (void)unregisterAsObserver @@ -383,7 +382,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. @@ -470,7 +469,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 @@ -550,9 +549,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/SUUserInitiatedUpdateDriver.m b/SUUserInitiatedUpdateDriver.m index 276b032b..b97632b3 100644 --- a/SUUserInitiatedUpdateDriver.m +++ b/SUUserInitiatedUpdateDriver.m @@ -18,7 +18,6 @@ if (checkingController) { [[checkingController window] close]; - [checkingController release]; checkingController = nil; } } diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 067d768c..54d2c5f5 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -58,7 +58,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 */; }; @@ -126,7 +126,7 @@ 61BBDF820A49220C00378739 /* Sparkle.icns in Resources */ = {isa = PBXBuildFile; fileRef = 61BBDF810A49220C00378739 /* Sparkle.icns */; }; 61C2680A0E2DB5D000175E6C /* License.txt in Resources */ = {isa = PBXBuildFile; fileRef = 61C268090E2DB5D000175E6C /* License.txt */; }; 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 */; }; diff --git a/finish_installation.m b/finish_installation.m index 90186f0f..5a5b8e0b 100644 --- a/finish_installation.m +++ b/finish_installation.m @@ -49,7 +49,7 @@ executablepath = execpath; parentprocessid = ppid; folderpath = infolderpath; - selfPath = [inSelfPath retain]; + selfPath = inSelfPath; shouldRelaunch = relaunch; shouldShowUI = showUI; @@ -58,7 +58,7 @@ if( alreadyTerminated ) [self parentHasQuit]; else - watchdogTimer = [[NSTimer scheduledTimerWithTimeInterval:CHECK_FOR_PARENT_TO_QUIT_TIME target:self selector:@selector(watchdog:) userInfo:nil repeats:YES] retain]; + watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:CHECK_FOR_PARENT_TO_QUIT_TIME target:self selector:@selector(watchdog:) userInfo:nil repeats:YES]; return self; } @@ -67,30 +67,15 @@ -(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: LONG_INSTALLATION_TIME + longInstallationTimer = [NSTimer scheduledTimerWithTimeInterval: LONG_INSTALLATION_TIME target: self selector: @selector(showAppIconInDock:) - userInfo:nil repeats:NO] retain]; + userInfo:nil repeats:NO]; if( folderpath ) [self install]; @@ -148,7 +133,6 @@ [statusCtl beginActionWithTitle: SULocalizedString(@"Installing update...",@"") maxProgressValue: 0 statusText: @""]; [statusCtl showWindow: self]; - [statusCtl release]; } [SUInstaller installFromUpdateFolder: [[NSFileManager defaultManager] stringWithFileSystemRepresentation: folderpath length: strlen(folderpath)] @@ -203,13 +187,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]) : 1 shouldShowUI: shouldShowUI - selfPath: selfPath] autorelease]; + selfPath: selfPath]; + + [termListen class]; [[NSApplication sharedApplication] run]; } From 1a968424db71233acbfe47292a8357b922971b3a Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Mon, 30 Jun 2014 18:57:01 -0600 Subject: [PATCH 2/3] Force Xcode to use spaces on source code files. --- Sparkle.xcodeproj/project.pbxproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 947c69bc..1d83d0b1 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -25,8 +25,8 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 1420DE301962082C00203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DE2F1962082C00203BB0 /* Images.xcassets */; }; - 1420DE3119620A6600203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DE2F1962082C00203BB0 /* Images.xcassets */; }; + 1420DE301962082C00203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DE2F1962082C00203BB0 /* Images.xcassets */; }; + 1420DE3119620A6600203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DE2F1962082C00203BB0 /* Images.xcassets */; }; 14732BC01960F2C200593899 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 14732BBF1960F0AC00593899 /* dsa_pub.pem */; }; 14732BD019610A0D00593899 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; }; 14732BD119610A1200593899 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; }; @@ -262,8 +262,7 @@ 0263187714FEBB42005EBF43 /* uk */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = uk; path = uk.lproj/SUUpdatePermissionPrompt.xib; sourceTree = ""; }; 0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; - 1420DE2F1962082C00203BB0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 14732BB1195FF6B700593899 /* .clang-format */ = {isa = PBXFileReference; lastKnownFileType = text; path = ".clang-format"; sourceTree = SOURCE_ROOT; }; + 1420DE2F1962082C00203BB0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 14732BB91960EEEE00593899 /* SampleAppcast.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = SampleAppcast.xml; sourceTree = ""; }; 14732BBA1960EF7100593899 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGELOG; sourceTree = SOURCE_ROOT; }; 14732BBC1960EFB500593899 /* README.markdown */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.markdown; sourceTree = SOURCE_ROOT; }; @@ -585,6 +584,7 @@ ); name = Sparkle; sourceTree = ""; + usesTabs = 0; }; 0867D69AFE84028FC02AAC07 /* Frameworks */ = { isa = PBXGroup; @@ -656,7 +656,7 @@ 14732BBC1960EFB500593899 /* README.markdown */, 14732BC11960F3B200593899 /* Makefile */, 14732BB91960EEEE00593899 /* SampleAppcast.xml */, - 1420DE2F1962082C00203BB0 /* Images.xcassets */, + 1420DE2F1962082C00203BB0 /* Images.xcassets */, 615AE3CF0D64DC40001CA7BD /* SUModelTranslation.plist */, ); path = Resources; @@ -1134,7 +1134,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 1420DE3119620A6600203BB0 /* Images.xcassets in Resources */, + 1420DE3119620A6600203BB0 /* Images.xcassets in Resources */, 55C14FC7136F05E100649790 /* Sparkle.strings in Resources */, 55C14BD9136EF00C00649790 /* SUStatus.xib in Resources */, ); @@ -1152,7 +1152,7 @@ buildActionMask = 2147483647; files = ( 14732BC01960F2C200593899 /* dsa_pub.pem in Resources */, - 1420DE301962082C00203BB0 /* Images.xcassets in Resources */, + 1420DE301962082C00203BB0 /* Images.xcassets in Resources */, 61B5F92E09C4CFD800B25A18 /* InfoPlist.strings in Resources */, 61B5F92F09C4CFD800B25A18 /* MainMenu.xib in Resources */, ); @@ -1683,7 +1683,7 @@ 14732BC81960F69300593899 /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; + defaultConfigurationName = Release; }; 14950060195FB89500BC5B5B /* Build configuration list for PBXAggregateTarget "All" */ = { isa = XCConfigurationList; From b87a89c24d0d689ca765c1ae561543ca08a4a832 Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Mon, 30 Jun 2014 19:03:26 -0600 Subject: [PATCH 3/3] Fix a release bug. --- Sparkle/SUCodeSigningVerifier.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUCodeSigningVerifier.m b/Sparkle/SUCodeSigningVerifier.m index ba4e82e6..2c74de55 100644 --- a/Sparkle/SUCodeSigningVerifier.m +++ b/Sparkle/SUCodeSigningVerifier.m @@ -61,8 +61,9 @@ [self logSigningInfoForCode:hostCode label:@"host info"]; [self logSigningInfoForCode:staticCode label:@"new info"]; - *error = CFBridgingRelease(cfError); } + + *error = CFBridgingRelease(cfError); } finally: