diff options
author | Max <post@wickenrode.com> | 2015-01-04 03:57:26 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-01-04 03:57:26 +0100 |
commit | 2735e15bf5d4b3a976435ebb29ca9073de0e5071 (patch) | |
tree | e2088e442aa2d100ceafd8c0c4789e033fd12ac3 /Source | |
parent | db64bd1b5affd00332906901ee57d6f681faf7ea (diff) | |
download | sequelpro-2735e15bf5d4b3a976435ebb29ca9073de0e5071.tar.gz sequelpro-2735e15bf5d4b3a976435ebb29ca9073de0e5071.tar.bz2 sequelpro-2735e15bf5d4b3a976435ebb29ca9073de0e5071.zip |
Formalize [x release], x = nil; convention
Take this commit as a proposal to formalize our existing "[x release], x = nil;" convention by introducing a macro for it.
Feel free to revert this commit if you see issues with the approch or implementation.
Diffstat (limited to 'Source')
61 files changed, 333 insertions, 322 deletions
diff --git a/Source/DMLocalizedNib.m b/Source/DMLocalizedNib.m index 56f6a810..4a03247a 100644 --- a/Source/DMLocalizedNib.m +++ b/Source/DMLocalizedNib.m @@ -154,7 +154,7 @@ static NSMutableDictionary *deliciousNibNames = nil; { if (deliciousNibNames) { [deliciousNibNames removeObjectForKey:[NSValue valueWithPointer:self]]; - if (![deliciousNibNames count]) [deliciousNibNames release], deliciousNibNames = nil; + if (![deliciousNibNames count]) SPClear(deliciousNibNames); } [self deliciousDealloc]; } diff --git a/Source/GeneratePreviewForURL.m b/Source/GeneratePreviewForURL.m index 1062f11d..ef20b852 100644 --- a/Source/GeneratePreviewForURL.m +++ b/Source/GeneratePreviewForURL.m @@ -78,8 +78,8 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError] retain]; if(!spf || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) { - if(spf) [spf release], spf = nil; - if(pool) [pool release], pool = nil; + if(spf) SPClear(spf); + if(pool) SPClear(pool); return noErr; } @@ -89,8 +89,8 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, encoding:NSUTF8StringEncoding error:&templateReadError]; if (template == nil || ![template length] || templateReadError != nil) { - if(spf) [spf release], spf = nil; - if(pool) [pool release], pool = nil; + if(spf) SPClear(spf); + if(pool) SPClear(pool); return noErr; } @@ -146,8 +146,8 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, encoding:NSUTF8StringEncoding error:&templateReadError]; if (template == nil || ![template length] || templateReadError != nil) { - if(spf) [spf release], spf = nil; - if(pool) [pool release], pool = nil; + if(spf) SPClear(spf); + if(pool) SPClear(pool); return noErr; } // compose the html @@ -162,8 +162,8 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, encoding:NSUTF8StringEncoding error:&templateReadError]; if (template == nil || ![template length] || templateReadError != nil) { - if(spf) [spf release], spf = nil; - if(pool) [pool release], pool = nil; + if(spf) SPClear(spf); + if(pool) SPClear(pool); return noErr; } // compose the html @@ -182,7 +182,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, encoding:NSUTF8StringEncoding error:&templateReadError]; if (template == nil || ![template length] || templateReadError != nil) { - if(pool) [pool release], pool = nil; + if(pool) SPClear(pool); return noErr; } @@ -190,7 +190,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, encoding:NSUTF8StringEncoding error:&templateReadError]; if (windowTemplate == nil || ![windowTemplate length] || templateReadError != nil) { - if(pool) [pool release], pool = nil; + if(pool) SPClear(pool); return noErr; } @@ -205,8 +205,8 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError] retain]; if(!spf || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) { - if(spf) [spf release], spf = nil; - if(pool) [pool release], pool = nil; + if(spf) SPClear(spf); + if(pool) SPClear(pool); return noErr; } @@ -323,7 +323,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, encoding:NSUTF8StringEncoding error:&templateReadError]; if (template == nil || ![template length] || templateReadError != nil) { - if(pool) [pool release], pool = nil; + if(pool) SPClear(pool); return noErr; } @@ -418,10 +418,10 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, [sqlHTML appendFormat:@"<font color=%@>%@</font>", tokenColor, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]]; if (QLPreviewRequestIsCancelled(preview)) { - if(sqlHTML) [sqlHTML release], sqlHTML = nil; + if(sqlHTML) SPClear(sqlHTML); if(truncatedString) [truncatedString release], sqlHTML = nil; if(sqlText) [sqlText release], sqlHTML = nil; - if(pool) [pool release], pool = nil; + if(pool) SPClear(pool); [loopPool release]; return noErr; } @@ -457,7 +457,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, } else { // No file attributes were read, bail for safety reasons - if(pool) [pool release], pool = nil; + if(pool) SPClear(pool); return noErr; } diff --git a/Source/NoodleLineNumberView.m b/Source/NoodleLineNumberView.m index 1d58bbed..24b76be1 100644 --- a/Source/NoodleLineNumberView.m +++ b/Source/NoodleLineNumberView.m @@ -497,7 +497,7 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); - (void)invalidateLineIndices { - if (lineIndices) [lineIndices release], lineIndices = nil; + if (lineIndices) SPClear(lineIndices); } diff --git a/Source/SPActivityTextFieldCell.m b/Source/SPActivityTextFieldCell.m index 5eb2deda..b82fa995 100644 --- a/Source/SPActivityTextFieldCell.m +++ b/Source/SPActivityTextFieldCell.m @@ -324,9 +324,9 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect) */ - (void)dealloc { - if(activityName) [activityName release], activityName = nil; - if(activityInfo) [activityInfo release], activityInfo = nil; - if(contextInfo) [contextInfo release], contextInfo = nil; + if(activityName) SPClear(activityName); + if(activityInfo) SPClear(activityInfo); + if(contextInfo) SPClear(contextInfo); if(cancelButton) [cancelButton release]; [super dealloc]; diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 3f9db630..87cf9f24 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -1355,7 +1355,7 @@ */ - (void)setSessionURL:(NSString *)urlString { - if(_sessionURL) [_sessionURL release], _sessionURL = nil; + if(_sessionURL) SPClear(_sessionURL); if(urlString) _sessionURL = [[NSURL fileURLWithPath:urlString] retain]; } @@ -2240,13 +2240,13 @@ if (installedBundleUUIDs) [installedBundleUUIDs release]; if (runningActivitiesArray) [runningActivitiesArray release]; - [prefsController release], prefsController = nil; + SPClear(prefsController); - if (aboutController) [aboutController release], aboutController = nil; - if (bundleEditorController) [bundleEditorController release], bundleEditorController = nil; + if (aboutController) SPClear(aboutController); + if (bundleEditorController) SPClear(bundleEditorController); - if (_sessionURL) [_sessionURL release], _sessionURL = nil; - if (_spfSessionDocData) [_spfSessionDocData release], _spfSessionDocData = nil; + if (_sessionURL) SPClear(_sessionURL); + if (_spfSessionDocData) SPClear(_spfSessionDocData); [super dealloc]; } diff --git a/Source/SPBundleCommandRunner.m b/Source/SPBundleCommandRunner.m index 45184618..08fad6f1 100644 --- a/Source/SPBundleCommandRunner.m +++ b/Source/SPBundleCommandRunner.m @@ -297,7 +297,7 @@ // Read STDOUT saved to file if([fm fileExistsAtPath:stdoutFilePath isDirectory:nil]) { NSString *stdoutContent = [NSString stringWithContentsOfFile:stdoutFilePath encoding:NSUTF8StringEncoding error:nil]; - if(bashTask) [bashTask release], bashTask = nil; + if(bashTask) SPClear(bashTask); [fm removeItemAtPath:stdoutFilePath error:nil]; if(stdoutContent != nil) { if (status == 0) { diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m index ac227cf4..69652bf1 100644 --- a/Source/SPBundleEditorController.m +++ b/Source/SPBundleEditorController.m @@ -1093,7 +1093,7 @@ static NSString *SPSaveBundleAction = @"SPSaveBundle"; [draggedFilePath release]; draggedFilePath = nil; } - if(oldBundleName) [oldBundleName release], oldBundleName = nil; + if(oldBundleName) SPClear(oldBundleName); } #pragma mark - @@ -1234,13 +1234,13 @@ static NSString *SPSaveBundleAction = @"SPSaveBundle"; // Remember selected bundle name to reset the name if the user cancelled // the editing of the bundle name - if(oldBundleName) [oldBundleName release], oldBundleName = nil; + if(oldBundleName) SPClear(oldBundleName); if(![[self _currentSelectedObject] objectForKey:kChildrenKey]) { oldBundleName = [[[self _currentSelectedObject] objectForKey:kBundleNameKey] retain]; [self _enableBundleDataInput:YES bundleEnabled:![[[self _currentSelectedObject] objectForKey:@"disabled"] boolValue]]; } else { [self _enableBundleDataInput:NO bundleEnabled:NO]; - if(oldBundleName) [oldBundleName release], oldBundleName = nil; + if(oldBundleName) SPClear(oldBundleName); } // Remember the selected bundle name in touchedBundleArray to save only those @@ -1386,7 +1386,7 @@ static NSString *SPSaveBundleAction = @"SPSaveBundle"; [commandBundleTreeController rearrangeObjects]; [commandsOutlineView reloadData]; - if(oldBundleName) [oldBundleName release], oldBundleName = nil; + if(oldBundleName) SPClear(oldBundleName); oldBundleName = [[[self _currentSelectedObject] objectForKey:kBundleNameKey] retain]; if(oldBundleName != nil && ![touchedBundleArray containsObject:oldBundleName]) [touchedBundleArray addObject:oldBundleName]; @@ -2102,11 +2102,11 @@ static NSString *SPSaveBundleAction = @"SPSaveBundle"; [shellVariableSuggestions release]; [deletedDefaultBundles release]; - if (touchedBundleArray) [touchedBundleArray release], touchedBundleArray = nil; - if (commandBundleTree) [commandBundleTree release], commandBundleTree = nil; - if (sortDescriptor) [sortDescriptor release], sortDescriptor = nil; - if (bundlePath) [bundlePath release], bundlePath = nil; - if (esUndoManager) [esUndoManager release], esUndoManager = nil; + if (touchedBundleArray) SPClear(touchedBundleArray); + if (commandBundleTree) SPClear(commandBundleTree); + if (sortDescriptor) SPClear(sortDescriptor); + if (bundlePath) SPClear(bundlePath); + if (esUndoManager) SPClear(esUndoManager); [super dealloc]; } diff --git a/Source/SPCSVExporter.m b/Source/SPCSVExporter.m index dd244410..5fb6f664 100644 --- a/Source/SPCSVExporter.m +++ b/Source/SPCSVExporter.m @@ -415,15 +415,15 @@ - (void)dealloc { - if (csvDataArray) [csvDataArray release], csvDataArray = nil; - if (csvTableName) [csvTableName release], csvTableName = nil; + if (csvDataArray) SPClear(csvDataArray); + if (csvTableName) SPClear(csvTableName); - [csvFieldSeparatorString release], csvFieldSeparatorString = nil; - [csvEnclosingCharacterString release], csvEnclosingCharacterString = nil; - [csvEscapeString release], csvEscapeString = nil; - [csvLineEndingString release], csvLineEndingString = nil; - [csvNULLString release], csvNULLString = nil; - [csvTableData release], csvTableData = nil; + SPClear(csvFieldSeparatorString); + SPClear(csvEnclosingCharacterString); + SPClear(csvEscapeString); + SPClear(csvLineEndingString); + SPClear(csvNULLString); + SPClear(csvTableData); [super dealloc]; } diff --git a/Source/SPCSVParser.m b/Source/SPCSVParser.m index 09d8c989..88a2fbb5 100644 --- a/Source/SPCSVParser.m +++ b/Source/SPCSVParser.m @@ -469,7 +469,7 @@ */ - (void) setNullReplacementString:(NSString *)nullString { - if (nullReplacementString) [nullReplacementString release], nullReplacementString = nil; + if (nullReplacementString) SPClear(nullReplacementString); if (nullString) nullReplacementString = [[NSString alloc] initWithString:nullString]; } @@ -576,7 +576,7 @@ { NSMutableString *charactersToSkip; - if (skipCharacterSet) [skipCharacterSet release], skipCharacterSet = nil; + if (skipCharacterSet) SPClear(skipCharacterSet); charactersToSkip = [[NSMutableString alloc] init]; if (![fieldEndString isEqualToString:@" "] && ![fieldQuoteString isEqualToString:@" "] && ![escapeString isEqualToString:@" "] && ![lineEndString isEqualToString:@" "]) diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 82c29510..651d3538 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -256,8 +256,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [[sshPasswordField undoManager] removeAllActionsWithTarget:sshPasswordField]; } else { - [connectionKeychainItemName release], connectionKeychainItemName = nil; - [connectionKeychainItemAccount release], connectionKeychainItemAccount = nil; + SPClear(connectionKeychainItemName); + SPClear(connectionKeychainItemAccount); } } @@ -267,8 +267,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [[sshSSHPasswordField undoManager] removeAllActionsWithTarget:sshSSHPasswordField]; } else { - [connectionSSHKeychainItemName release], connectionSSHKeychainItemName = nil; - [connectionSSHKeychainItemAccount release], connectionSSHKeychainItemAccount = nil; + SPClear(connectionSSHKeychainItemName); + SPClear(connectionSSHKeychainItemAccount); } } #endif @@ -608,11 +608,11 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, #ifndef SP_CODA // Clear the keychain referral items as appropriate - if (connectionKeychainID) [connectionKeychainID release], connectionKeychainID = nil; - if (connectionKeychainItemName) [connectionKeychainItemName release], connectionKeychainItemName = nil; - if (connectionKeychainItemAccount) [connectionKeychainItemAccount release], connectionKeychainItemAccount = nil; - if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release], connectionSSHKeychainItemName = nil; - if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release], connectionSSHKeychainItemAccount = nil; + if (connectionKeychainID) SPClear(connectionKeychainID); + if (connectionKeychainItemName) SPClear(connectionKeychainItemName); + if (connectionKeychainItemAccount) SPClear(connectionKeychainItemAccount); + if (connectionSSHKeychainItemName) SPClear(connectionSSHKeychainItemName); + if (connectionSSHKeychainItemAccount) SPClear(connectionSSHKeychainItemAccount); SPTreeNode *node = [self selectedFavoriteNode]; if ([node isGroup]) node = nil; @@ -621,7 +621,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, NSDictionary *fav = [[node representedObject] nodeFavorite]; // Keep a copy of the favorite as it currently stands - if (currentFavorite) [currentFavorite release], currentFavorite = nil; + if (currentFavorite) SPClear(currentFavorite); currentFavorite = [fav copy]; [connectionResizeContainer setHidden:NO]; @@ -669,8 +669,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if (![[self password] length]) { [self setPassword:nil]; - [connectionKeychainItemName release], connectionKeychainItemName = nil; - [connectionKeychainItemAccount release], connectionKeychainItemAccount = nil; + SPClear(connectionKeychainItemName); + SPClear(connectionKeychainItemAccount); } // Store the selected favorite ID for use with the document on connection @@ -684,8 +684,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if (![[self sshPassword] length]) { [self setSshPassword:nil]; - [connectionSSHKeychainItemName release], connectionSSHKeychainItemName = nil; - [connectionSSHKeychainItemAccount release], connectionSSHKeychainItemAccount = nil; + SPClear(connectionSSHKeychainItemName); + SPClear(connectionSSHKeychainItemAccount); } [prefs setInteger:[[fav objectForKey:SPFavoriteIDKey] integerValue] forKey:SPLastFavoriteID]; @@ -1365,7 +1365,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [self _stopEditingConnection]; - if (currentFavorite) [currentFavorite release], currentFavorite = nil; + if (currentFavorite) SPClear(currentFavorite); currentFavorite = [theFavorite copy]; [self _sortFavorites]; @@ -1888,9 +1888,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [prefs release]; #ifndef SP_CODA - [folderImage release], folderImage = nil; - [quickConnectItem release], quickConnectItem = nil; - [quickConnectCell release], quickConnectCell = nil; + SPClear(folderImage); + SPClear(quickConnectItem); + SPClear(quickConnectCell); #endif for (id retainedObject in nibObjectsToRelease) [retainedObject release]; @@ -1904,7 +1904,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release]; #ifndef SP_CODA - if (currentFavorite) [currentFavorite release], currentFavorite = nil; + if (currentFavorite) SPClear(currentFavorite); #endif [super dealloc]; diff --git a/Source/SPConnectionHandler.m b/Source/SPConnectionHandler.m index 12b868f5..bac0c680 100644 --- a/Source/SPConnectionHandler.m +++ b/Source/SPConnectionHandler.m @@ -208,9 +208,9 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; // Tidy up isConnecting = NO; - if (sshTunnel) [sshTunnel disconnect], [sshTunnel release], sshTunnel = nil; + if (sshTunnel) [sshTunnel disconnect], SPClear(sshTunnel); - [mySQLConnection release], mySQLConnection = nil; + SPClear(mySQLConnection); #ifndef SP_CODA if (!cancellingConnection) [self _restoreConnectionInterface]; #endif @@ -229,9 +229,9 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; // Tidy up isConnecting = NO; - if (sshTunnel) [sshTunnel release], sshTunnel = nil; + if (sshTunnel) SPClear(sshTunnel); - [mySQLConnection release], mySQLConnection = nil; + SPClear(mySQLConnection); [self _restoreConnectionInterface]; if (isTestingConnection) { [self _showConnectionTestResult:NSLocalizedString(@"Invalid database", @"Invalid database very short status message")]; @@ -352,7 +352,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; #endif // Release the tunnel if set - will now be retained by the connection - if (sshTunnel) [sshTunnel release], sshTunnel = nil; + if (sshTunnel) SPClear(sshTunnel); // Pass the connection to the document and clean up the interface [self addConnectionToDocument]; @@ -436,7 +436,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; // Release as appropriate if (sshTunnel) { - [sshTunnel disconnect], [sshTunnel release], sshTunnel = nil; + [sshTunnel disconnect], SPClear(sshTunnel); // If the SSH tunnel connection failed because the port it was trying to bind to was already in use take note // of it so we can give the user the option of connecting via standard connection and use the existing tunnel. diff --git a/Source/SPConsoleMessage.m b/Source/SPConsoleMessage.m index 6ada323a..eb7573f9 100644 --- a/Source/SPConsoleMessage.m +++ b/Source/SPConsoleMessage.m @@ -65,10 +65,10 @@ - (void)dealloc { - [message release], message = nil; - [messageDate release], messageDate = nil; - [messageDatabase release], messageDatabase = nil; - [messageConnection release], messageConnection = nil; + SPClear(message); + SPClear(messageDate); + SPClear(messageDatabase); + SPClear(messageConnection); [super dealloc]; } diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 415fd4da..f0350f07 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -612,6 +612,13 @@ extern NSString *SPURLSchemeQueryResultMetaPathHeader; #define SPAppDelegate ((SPAppController *)[NSApp delegate]) +// Provides a standard method for our "[x release], x = nil;" convention. +// Yes, this could have been done with a preprocessor macro alone, however +// a function works more nicely in the debugger and in production code +// the optimizer will most likely remove all overhead by inlining anyway :) +void _SPClear(id *addr); +#define SPClear(x) _SPClear(&x) + //Backwards compatibility #ifndef __MAC_10_7 #define __MAC_10_7 1070 diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 23d8c378..292acb3c 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -417,3 +417,7 @@ NSString *SPURLSchemeQueryInputPathHeader = @"/tmp/SP_QUERY_"; NSString *SPURLSchemeQueryResultPathHeader = @"/tmp/SP_QUERY_RESULT_"; NSString *SPURLSchemeQueryResultStatusPathHeader = @"/tmp/SP_QUERY_RESULT_STATUS_"; NSString *SPURLSchemeQueryResultMetaPathHeader = @"/tmp/SP_QUERY_META_"; + +void inline _SPClear(id *addr) { + [*addr release], *addr = nil; +} diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index 3efc132a..7aaae1a6 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -219,7 +219,7 @@ static const NSInteger kBlobAsImageFile = 4; if (image) { NSData *d = [[NSData alloc] initWithData:[image TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1]]; [d writeToFile:fp atomically:NO]; - if(d) [d release], d = nil; + if(d) SPClear(d); [image release]; } else { NSString *noData = @""; @@ -242,7 +242,7 @@ static const NSInteger kBlobAsImageFile = 4; } else { [result appendFormat:@"%@\t", [cellData wktString]]; } - if(v) [v release], v = nil; + if(v) SPClear(v); } else { [result appendFormat:@"%@\t", [cellData wktString]]; } @@ -358,7 +358,7 @@ static const NSInteger kBlobAsImageFile = 4; if (image) { NSData *d = [[NSData alloc] initWithData:[image TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1]]; [d writeToFile:fp atomically:NO]; - if(d) [d release], d = nil; + if(d) SPClear(d); [image release]; } else { NSString *noData = @""; @@ -381,7 +381,7 @@ static const NSInteger kBlobAsImageFile = 4; } else { [result appendFormat:@"\"%@\",", [cellData wktString]]; } - if(v) [v release], v = nil; + if(v) SPClear(v); } else { [result appendFormat:@"\"%@\",", [cellData wktString]]; } @@ -698,7 +698,7 @@ static const NSInteger kBlobAsImageFile = 4; tableInstance = anInstance; tableStorage = theTableStorage; - if (columnDefinitions) [columnDefinitions release], columnDefinitions = nil; + if (columnDefinitions) SPClear(columnDefinitions); columnDefinitions = [[NSArray alloc] initWithArray:columnDefs]; } diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 8b201776..2114d766 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -141,7 +141,7 @@ // Re-init sort order isDesc = NO; sortColumn = nil; - if(sortField) [sortField release], sortField = nil; + if(sortField) SPClear(sortField); // Retrieve the custom query string and split it into separate SQL queries queryParser = [[SPSQLParser alloc] initWithString:[textView string]]; @@ -185,7 +185,7 @@ // Re-init sort order isDesc = NO; sortColumn = nil; - if(sortField) [sortField release], sortField = nil; + if(sortField) SPClear(sortField); // If the current selection is a single caret position, run the current query. if (selectedRange.length == 0) { @@ -628,7 +628,7 @@ // Remove all the columns if not reloading the table if(!reloadingExistingResult) { - if (cqColumnDefinition) [cqColumnDefinition release], cqColumnDefinition = nil; + if (cqColumnDefinition) SPClear(cqColumnDefinition); [[self onMainThread] updateTableView]; } @@ -1736,7 +1736,7 @@ */ - (void)setResultSelectedRowIndexesToRestore:(NSIndexSet *)theIndexSet { - if (selectionIndexToRestore) [selectionIndexToRestore release], selectionIndexToRestore = nil; + if (selectionIndexToRestore) SPClear(selectionIndexToRestore); if (theIndexSet) selectionIndexToRestore = [[NSIndexSet alloc] initWithIndexSet:theIndexSet]; } @@ -2273,7 +2273,7 @@ if ([mySQLConnection queryErrored]) { sortColumn = nil; - if(sortField) [sortField release], sortField = nil; + if(sortField) SPClear(sortField); return; } @@ -2449,7 +2449,7 @@ // Open the editing sheet if required if ([customQueryView shouldUseFieldEditorForRow:rowIndex column:[[aTableColumn identifier] integerValue] checkWithLock:NULL]) { - if (fieldEditor) [fieldEditor release], fieldEditor = nil; + if (fieldEditor) SPClear(fieldEditor); fieldEditor = [[SPFieldEditorController alloc] init]; // Remember edited row for reselecting and setting the scroll view after reload @@ -4042,7 +4042,7 @@ [resultData release]; [favoritesManager release]; - if(fieldEditor) [fieldEditor release], fieldEditor = nil; + if(fieldEditor) SPClear(fieldEditor); #ifndef SP_CODA if (helpHTMLTemplate) [helpHTMLTemplate release]; diff --git a/Source/SPDataCellFormatter.m b/Source/SPDataCellFormatter.m index 2cd3b8c8..6c6cd913 100644 --- a/Source/SPDataCellFormatter.m +++ b/Source/SPDataCellFormatter.m @@ -140,7 +140,7 @@ - (void)dealloc { - if (fieldType) [fieldType release], fieldType = nil; + if (fieldType) SPClear(fieldType); [super dealloc]; } diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index f1208a54..be3935c4 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -1324,7 +1324,7 @@ cleanup: dispatch_async(dispatch_get_main_queue(), ^{ - if(fieldMapperController) [fieldMapperController release], fieldMapperController = nil; + if(fieldMapperController) SPClear(fieldMapperController); }); return success; @@ -1715,13 +1715,13 @@ cleanup: */ - (void)_resetFieldMappingGlobals { - if (csvImportTailString) [csvImportTailString release], csvImportTailString = nil; - if (csvImportHeaderString) [csvImportHeaderString release], csvImportHeaderString = nil; - if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; - if (fieldMappingGlobalValueArray) [fieldMappingGlobalValueArray release], fieldMappingGlobalValueArray = nil; - if (fieldMappingTableColumnNames) [fieldMappingTableColumnNames release], fieldMappingTableColumnNames = nil; - if (fieldMappingTableDefaultValues) [fieldMappingTableDefaultValues release], fieldMappingTableDefaultValues = nil; - if (fieldMapperOperator) [fieldMapperOperator release], fieldMapperOperator = nil; + if (csvImportTailString) SPClear(csvImportTailString); + if (csvImportHeaderString) SPClear(csvImportHeaderString); + if (fieldMappingArray) SPClear(fieldMappingArray); + if (fieldMappingGlobalValueArray) SPClear(fieldMappingGlobalValueArray); + if (fieldMappingTableColumnNames) SPClear(fieldMappingTableColumnNames); + if (fieldMappingTableDefaultValues) SPClear(fieldMappingTableDefaultValues); + if (fieldMapperOperator) SPClear(fieldMapperOperator); } #pragma mark - diff --git a/Source/SPDataStorage.m b/Source/SPDataStorage.m index 30be0644..3db04159 100644 --- a/Source/SPDataStorage.m +++ b/Source/SPDataStorage.m @@ -58,7 +58,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore { NSUInteger i; editedRowCount = 0; - [editedRows release], editedRows = nil; + SPClear(editedRows); if (unloadedColumns) free(unloadedColumns), unloadedColumns = NULL; if (dataStorage) { @@ -68,7 +68,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore [newDataStorage replaceExistingResultStore:dataStorage]; } - [dataStorage release], dataStorage = nil; + SPClear(dataStorage); } dataStorage = [newDataStorage retain]; @@ -449,8 +449,8 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore } - (void) dealloc { - [dataStorage release], dataStorage = nil; - [editedRows release], editedRows = nil; + SPClear(dataStorage); + SPClear(editedRows); if (unloadedColumns) free(unloadedColumns), unloadedColumns = NULL; [super dealloc]; diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m index 58ffa2d2..4856505d 100644 --- a/Source/SPDatabaseData.m +++ b/Source/SPDatabaseData.m @@ -82,11 +82,11 @@ NSInteger _sortStorageEngineEntry(NSDictionary *itemOne, NSDictionary *itemTwo, */ - (void)resetAllData { - if (characterSetEncoding != nil) [characterSetEncoding release], characterSetEncoding = nil; - if (defaultCollation != nil) [defaultCollation release], defaultCollation = nil; - if (defaultCharacterSetEncoding != nil) [defaultCharacterSetEncoding release], defaultCharacterSetEncoding = nil; - if (serverDefaultCharacterSetEncoding) [serverDefaultCharacterSetEncoding release], serverDefaultCharacterSetEncoding = nil; - if (serverDefaultCollation) [serverDefaultCollation release], serverDefaultCollation = nil; + if (characterSetEncoding != nil) SPClear(characterSetEncoding); + if (defaultCollation != nil) SPClear(defaultCollation); + if (defaultCharacterSetEncoding != nil) SPClear(defaultCharacterSetEncoding); + if (serverDefaultCharacterSetEncoding) SPClear(serverDefaultCharacterSetEncoding); + if (serverDefaultCollation) SPClear(serverDefaultCollation); [collations removeAllObjects]; [characterSetCollations removeAllObjects]; @@ -489,11 +489,11 @@ NSInteger _sortStorageEngineEntry(NSDictionary *itemOne, NSDictionary *itemTwo, { [self resetAllData]; - [collations release], collations = nil; - [characterSetCollations release], characterSetCollations = nil; - [storageEngines release], storageEngines = nil; - [characterSetEncodings release], characterSetEncodings = nil; - [cachedCollationsByEncoding release], cachedCollationsByEncoding = nil; + SPClear(collations); + SPClear(characterSetCollations); + SPClear(storageEngines); + SPClear(characterSetEncodings); + SPClear(cachedCollationsByEncoding); [super dealloc]; } diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 9f5ce128..6940abfb 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -473,7 +473,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; // Update the selected database if appropriate if ([connectionController database] && ![[connectionController database] isEqualToString:@""]) { - if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; + if (selectedDatabase) SPClear(selectedDatabase); selectedDatabase = [[NSString alloc] initWithString:[connectionController database]]; #ifndef SP_CODA /* [spHistoryControllerInstance updateHistoryEntries] */ [spHistoryControllerInstance updateHistoryEntries]; @@ -665,8 +665,8 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; [[chooseDatabaseButton menu] addItem:[NSMenuItem separatorItem]]; #endif - if (allDatabases) [allDatabases release]; - if (allSystemDatabases) [allSystemDatabases release]; + if (allDatabases) SPClear(allDatabases); + if (allSystemDatabases) SPClear(allSystemDatabases); NSArray *theDatabaseList = [mySQLConnection databases]; @@ -1056,7 +1056,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; #ifndef SP_CODA // Close error status sheet for OPTIMIZE, CHECK, REPAIR etc. else if ([contextInfo isEqualToString:@"statusError"]) { - if (statusValues) [statusValues release], statusValues = nil; + if (statusValues) SPClear(statusValues); } #endif } @@ -1096,7 +1096,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; if(![dbName isNSNull]) { if(![dbName isEqualToString:selectedDatabase]) { - if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; + if (selectedDatabase) SPClear(selectedDatabase); selectedDatabase = [[NSString alloc] initWithString:dbName]; [chooseDatabaseButton selectItemWithTitle:selectedDatabase]; #ifndef SP_CODA /* [self updateWindowTitle:self] */ @@ -1104,7 +1104,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; #endif } } else { - if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; + if (selectedDatabase) SPClear(selectedDatabase); [chooseDatabaseButton selectItemAtIndex:0]; #ifndef SP_CODA /* [self updateWindowTitle:self] */ [self updateWindowTitle:self]; @@ -1313,8 +1313,8 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; // If the window has been fully faded in, clean up the timer. if (alphaValue == 1.0) { - [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil; - [taskFadeInStartDate release], taskFadeInStartDate = nil; + [taskDrawTimer invalidate], SPClear(taskDrawTimer); + SPClear(taskFadeInStartDate); } #endif } @@ -1424,8 +1424,8 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; #ifndef SP_CODA // Cancel the draw timer if it exists if (taskDrawTimer) { - [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil; - [taskFadeInStartDate release], taskFadeInStartDate = nil; + [taskDrawTimer invalidate], SPClear(taskDrawTimer); + SPClear(taskFadeInStartDate); } // Hide the task interface and reset to indeterminate @@ -1712,7 +1712,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; NSString *mysqlEncoding = [databaseDataInstance getDatabaseDefaultCharacterSet]; - [selectedDatabaseEncoding release], selectedDatabaseEncoding = nil; + SPClear(selectedDatabaseEncoding); // Fallback or older version? -> set encoding to mysql default encoding latin1 if ( !mysqlEncoding ) { @@ -1953,7 +1953,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); - if (statusValues) [statusValues release], statusValues = nil; + if (statusValues) SPClear(statusValues); statusValues = [resultStatuses retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -2030,7 +2030,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); - if (statusValues) [statusValues release], statusValues = nil; + if (statusValues) SPClear(statusValues); statusValues = [resultStatuses retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -2107,7 +2107,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); - if (statusValues) [statusValues release], statusValues = nil; + if (statusValues) SPClear(statusValues); statusValues = [resultStatuses retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -2183,7 +2183,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); - if (statusValues) [statusValues release], statusValues = nil; + if (statusValues) SPClear(statusValues); statusValues = [resultStatuses retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -2259,7 +2259,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; contextInfo:NULL]; } else { message = NSLocalizedString(@"MySQL said:",@"mysql said message"); - if (statusValues) [statusValues release], statusValues = nil; + if (statusValues) SPClear(statusValues); statusValues = [resultStatuses retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:message]; @@ -2315,7 +2315,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; didEndSelector:NULL contextInfo:NULL]; } else { - if (statusValues) [statusValues release], statusValues = nil; + if (statusValues) SPClear(statusValues); statusValues = [resultStatuses retain]; NSAlert *alert = [[NSAlert new] autorelease]; [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Checksums of %@",@"Checksums of %@ message"), what]]; @@ -2487,7 +2487,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; [userManagerInstance beginSheetModalForWindow:parentWindow completionHandler:^(){ - [userManagerInstance release], userManagerInstance = nil; + SPClear(userManagerInstance); }]; } @@ -3044,7 +3044,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; [self saveDocumentWithFilePath:fileName inBackground:NO onlyPreferences:NO contextInfo:nil]; // Manually loaded nibs don't have their top-level objects released automatically - do that here. - [saveConnectionAccessory release]; + SPClear(saveConnectionAccessory); if(contextInfo == @"saveSPFfileAndClose") [self closeAndDisconnect]; @@ -4357,7 +4357,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; */ - (void)setFileURL:(NSURL *)theURL { - if (spfFileURL) [spfFileURL release], spfFileURL = nil; + if (spfFileURL) SPClear(spfFileURL); spfFileURL = [theURL retain]; if ([parentWindowController selectedTableDocument] == self) { if (spfFileURL && [spfFileURL isFileURL]) @@ -5016,8 +5016,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; [self updateWindowTitle:self]; // dealloc spfSession data - [spfSession release]; - spfSession = nil; + SPClear(spfSession); // End the task [self endTask]; @@ -6064,7 +6063,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; // that's why we can run this on main thread [databaseStructureRetrieval queryDbStructureWithUserInfo:nil]; - if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; + if (selectedDatabase) SPClear(selectedDatabase); [self setDatabases:self]; @@ -6134,7 +6133,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; #ifndef SP_CODA /* chooseDatabaseButton selectItemWithTitle: */ [[chooseDatabaseButton onMainThread] selectItemWithTitle:targetDatabaseName]; #endif - if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; + if (selectedDatabase) SPClear(selectedDatabase); selectedDatabase = [[NSString alloc] initWithString:targetDatabaseName]; [databaseDataInstance resetAllData]; @@ -6280,59 +6279,59 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; #ifndef SP_CODA /* release nib objects */ for (id retainedObject in nibObjectsToRelease) [retainedObject release]; - [nibObjectsToRelease release]; + SPClear(nibObjectsToRelease); #endif // Tell listeners that this database document is being closed - fixes retain cycles and allows cleanup [[NSNotificationCenter defaultCenter] postNotificationName:SPDocumentWillCloseNotification object:self]; - [databaseStructureRetrieval release]; + SPClear(databaseStructureRetrieval); - [allDatabases release]; - [allSystemDatabases release]; - [gotoDatabaseController release]; + SPClear(allDatabases); + SPClear(allSystemDatabases); + SPClear(gotoDatabaseController); #ifndef SP_CODA /* dealloc ivars */ - [undoManager release]; - [printWebView release]; + SPClear(undoManager); + SPClear(printWebView); #endif - [selectedDatabaseEncoding release]; + SPClear(selectedDatabaseEncoding); #ifndef SP_CODA [taskProgressWindow close]; #endif - if (selectedTableName) [selectedTableName release]; - if (connectionController) [connectionController release]; + if (selectedTableName) SPClear(selectedTableName); + if (connectionController) SPClear(connectionController); #ifndef SP_CODA /* dealloc ivars */ - if (processListController) [processListController release]; - if (serverVariablesController) [serverVariablesController release]; + if (processListController) SPClear(processListController); + if (serverVariablesController) SPClear(serverVariablesController); #endif - if (mySQLConnection) [mySQLConnection release], mySQLConnection = nil; - if (selectedDatabase) [selectedDatabase release]; - if (mySQLVersion) [mySQLVersion release]; + if (mySQLConnection) SPClear(mySQLConnection); + if (selectedDatabase) SPClear(selectedDatabase); + if (mySQLVersion) SPClear(mySQLVersion); #ifndef SP_CODA - if (taskDrawTimer) [taskDrawTimer invalidate], [taskDrawTimer release]; - if (taskFadeInStartDate) [taskFadeInStartDate release]; + if (taskDrawTimer) [taskDrawTimer invalidate], SPClear(taskDrawTimer); + if (taskFadeInStartDate) SPClear(taskFadeInStartDate); #endif - if (queryEditorInitString) [queryEditorInitString release]; + if (queryEditorInitString) SPClear(queryEditorInitString); #ifndef SP_CODA - if (sqlFileURL) [sqlFileURL release]; - if (spfFileURL) [spfFileURL release]; - if (spfPreferences) [spfPreferences release]; - if (spfSession) [spfSession release]; - if (spfDocData) [spfDocData release]; + if (sqlFileURL) SPClear(sqlFileURL); + if (spfFileURL) SPClear(spfFileURL); + if (spfPreferences) SPClear(spfPreferences); + if (spfSession) SPClear(spfSession); + if (spfDocData) SPClear(spfDocData); #endif - if (keyChainID) [keyChainID release]; + if (keyChainID) SPClear(keyChainID); #ifndef SP_CODA - if (mainToolbar) [mainToolbar release]; + if (mainToolbar) SPClear(mainToolbar); #endif - if (titleAccessoryView) [titleAccessoryView release]; + if (titleAccessoryView) SPClear(titleAccessoryView); #ifndef SP_CODA - if (taskProgressWindow) [taskProgressWindow release]; + if (taskProgressWindow) SPClear(taskProgressWindow); #endif - if (serverSupport) [serverSupport release]; + if (serverSupport) SPClear(serverSupport); #ifndef SP_CODA /* dealloc ivars */ - if (processID) [processID release]; - if (runningActivitiesArray) [runningActivitiesArray release]; + if (processID) SPClear(processID); + if (runningActivitiesArray) SPClear(runningActivitiesArray); #endif #ifdef SP_CODA @@ -6340,8 +6339,8 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; if (customQueryInstance) [customQueryInstance release]; #endif - if (alterDatabaseCharsetHelper) [alterDatabaseCharsetHelper release]; - if (addDatabaseCharsetHelper) [addDatabaseCharsetHelper release]; + if (alterDatabaseCharsetHelper) SPClear(alterDatabaseCharsetHelper); + if (addDatabaseCharsetHelper) SPClear(addDatabaseCharsetHelper); [super dealloc]; } diff --git a/Source/SPDatabaseStructure.m b/Source/SPDatabaseStructure.m index 70d0aee5..b34522c5 100644 --- a/Source/SPDatabaseStructure.m +++ b/Source/SPDatabaseStructure.m @@ -573,9 +573,9 @@ pthread_mutex_destroy(&dataLock); pthread_mutex_destroy(&connectionCheckLock); - if (mySQLConnection) [mySQLConnection release], mySQLConnection = nil; - if (structure) [structure release], structure = nil; - if (allKeysofDbStructure) [allKeysofDbStructure release], allKeysofDbStructure = nil; + if (mySQLConnection) SPClear(mySQLConnection); + if (structure) SPClear(structure); + if (allKeysofDbStructure) SPClear(allKeysofDbStructure); [super dealloc]; } diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m index 9b0ded39..c43761d3 100644 --- a/Source/SPDatabaseViewController.m +++ b/Source/SPDatabaseViewController.m @@ -332,7 +332,7 @@ if (!aTable) { // Update the selected table name and type - if (selectedTableName) [selectedTableName release], selectedTableName = nil; + if (selectedTableName) SPClear(selectedTableName); selectedTableType = SPTableTypeNone; diff --git a/Source/SPDotExporter.m b/Source/SPDotExporter.m index 249851ea..5f1dbd42 100644 --- a/Source/SPDotExporter.m +++ b/Source/SPDotExporter.m @@ -231,12 +231,12 @@ { delegate = nil; - [dotExportTables release], dotExportTables = nil; - [dotExportCurrentTable release], dotExportCurrentTable = nil; - [dotTableData release], dotTableData = nil; - [dotDatabaseHost release], dotDatabaseHost = nil; - [dotDatabaseName release], dotDatabaseName = nil; - [dotDatabaseVersion release], dotDatabaseVersion = nil; + SPClear(dotExportTables); + SPClear(dotExportCurrentTable); + SPClear(dotTableData); + SPClear(dotDatabaseHost); + SPClear(dotDatabaseName); + SPClear(dotDatabaseVersion); [super dealloc]; } diff --git a/Source/SPEditorPreferencePane.m b/Source/SPEditorPreferencePane.m index 08a833c2..7eaecf47 100644 --- a/Source/SPEditorPreferencePane.m +++ b/Source/SPEditorPreferencePane.m @@ -209,7 +209,7 @@ static NSString *SPCustomColorSchemeNameLC = @"user-defined"; if (![fm fileExistsAtPath:selectedPath isDirectory:nil]) { if ([fm copyItemAtPath:[NSString stringWithFormat:@"%@/%@.%@", themePath, [editThemeListItems objectAtIndex:[editThemeListTable selectedRow]], SPColorThemeFileExtension] toPath:selectedPath error:nil]) { - if (editThemeListItems) [editThemeListItems release], editThemeListItems = nil; + if (editThemeListItems) SPClear(editThemeListItems); editThemeListItems = [[NSArray arrayWithArray:[self _getAvailableThemes]] retain]; @@ -243,7 +243,7 @@ static NSString *SPCustomColorSchemeNameLC = @"user-defined"; [prefs setObject:SPCustomColorSchemeName forKey:SPCustomQueryEditorThemeName]; } - if (editThemeListItems) [editThemeListItems release], editThemeListItems = nil; + if (editThemeListItems) SPClear(editThemeListItems); editThemeListItems = [[NSArray arrayWithArray:[self _getAvailableThemes]] retain]; @@ -313,7 +313,7 @@ static NSString *SPCustomColorSchemeNameLC = @"user-defined"; { [[NSColorPanel sharedColorPanel] close]; - if (editThemeListItems) [editThemeListItems release], editThemeListItems = nil; + if (editThemeListItems) SPClear(editThemeListItems); editThemeListItems = [[NSArray arrayWithArray:[self _getAvailableThemes]] retain]; @@ -595,7 +595,7 @@ static NSString *SPCustomColorSchemeNameLC = @"user-defined"; } // Reload everything needed - if (editThemeListItems) [editThemeListItems release], editThemeListItems = nil; + if (editThemeListItems) SPClear(editThemeListItems); editThemeListItems = [[NSArray arrayWithArray:[self _getAvailableThemes]] retain]; [editThemeListTable reloadData]; @@ -1029,10 +1029,10 @@ static NSString *SPCustomColorSchemeNameLC = @"user-defined"; */ - (void)dealloc { - if (themePath) [themePath release], themePath = nil; - if (editThemeListItems) [editThemeListItems release], editThemeListItems = nil; - if (editorColors) [editorColors release], editorColors = nil; - if (editorNameForColors) [editorNameForColors release], editorNameForColors = nil; + if (themePath) SPClear(themePath); + if (editThemeListItems) SPClear(editThemeListItems); + if (editorColors) SPClear(editorColors); + if (editorNameForColors) SPClear(editorNameForColors); [super dealloc]; } diff --git a/Source/SPExportController.m b/Source/SPExportController.m index 4a97ae00..752e8521 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -1039,13 +1039,13 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; - (void)dealloc { - [tables release], tables = nil; - [exporters release], exporters = nil; - [exportFiles release], exportFiles = nil; - [operationQueue release], operationQueue = nil; - [exportFilename release], exportFilename = nil; + SPClear(tables); + SPClear(exporters); + SPClear(exportFiles); + SPClear(operationQueue); + SPClear(exportFilename); - if (previousConnectionEncoding) [previousConnectionEncoding release], previousConnectionEncoding = nil; + if (previousConnectionEncoding) SPClear(previousConnectionEncoding); [super dealloc]; } diff --git a/Source/SPExportFile.m b/Source/SPExportFile.m index c33aa076..132e1028 100644 --- a/Source/SPExportFile.m +++ b/Source/SPExportFile.m @@ -226,7 +226,7 @@ - (void)dealloc { - if (exportFileHandle) [exportFileHandle release], exportFileHandle = nil; + if (exportFileHandle) SPClear(exportFileHandle); [super dealloc]; } diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index 9c626a53..26cdd0dc 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -99,7 +99,7 @@ NSArray *dataArray = nil; // Get rid of the cached connection encoding - if (previousConnectionEncoding) [previousConnectionEncoding release], previousConnectionEncoding = nil; + if (previousConnectionEncoding) SPClear(previousConnectionEncoding); createCustomFilename = ([[exportCustomFilenameTokenField stringValue] length] > 0); diff --git a/Source/SPExporter.m b/Source/SPExporter.m index 7ec577b6..195d900d 100644 --- a/Source/SPExporter.m +++ b/Source/SPExporter.m @@ -103,9 +103,9 @@ */ - (void)dealloc { - if (exportData) [exportData release], exportData = nil; - if (connection) [connection release], connection = nil; - if (exportOutputFile) [exportOutputFile release], exportOutputFile = nil; + if (exportData) SPClear(exportData); + if (connection) SPClear(connection); + if (exportOutputFile) SPClear(exportOutputFile); [super dealloc]; } diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m index 2e9eb9e2..3d27b821 100644 --- a/Source/SPExtendedTableInfo.m +++ b/Source/SPExtendedTableInfo.m @@ -720,7 +720,7 @@ static NSString *SPMySQLCommentField = @"Comment"; { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [connection release], connection = nil; + SPClear(connection); [super dealloc]; } diff --git a/Source/SPFavoriteNode.m b/Source/SPFavoriteNode.m index aabb01c5..b2b99c64 100644 --- a/Source/SPFavoriteNode.m +++ b/Source/SPFavoriteNode.m @@ -103,7 +103,7 @@ static NSString *SPFavoriteNodeKey = @"SPFavoriteNode"; - (void)dealloc { - if (nodeFavorite) [nodeFavorite release], nodeFavorite = nil; + if (nodeFavorite) SPClear(nodeFavorite); [super dealloc]; } diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m index 76f376e8..ce6e5427 100644 --- a/Source/SPFavoritesController.m +++ b/Source/SPFavoritesController.m @@ -218,7 +218,7 @@ static SPFavoritesController *sharedFavoritesController = nil; NSError *error = nil; NSFileManager *fileManager = [NSFileManager defaultManager]; - if (favoritesData) [favoritesData release], favoritesData = nil; + if (favoritesData) SPClear(favoritesData); NSString *dataPath = [fileManager applicationSupportDirectoryForSubDirectory:SPDataSupportFolder error:&error]; @@ -468,8 +468,8 @@ static SPFavoritesController *sharedFavoritesController = nil; - (void)dealloc { - if (favoritesTree) [favoritesTree release], favoritesTree = nil; - if (favoritesData) [favoritesData release], favoritesData = nil; + if (favoritesTree) SPClear(favoritesTree); + if (favoritesData) SPClear(favoritesData); pthread_mutex_destroy(&writeLock); pthread_mutex_destroy(&favoritesLock); diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 9048cfe9..c223faf4 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -477,7 +477,7 @@ [usedSheet makeFirstResponder:image == nil || _isGeometry ? editTextView : editImage]; } - if (stringValue) [stringValue release], stringValue = nil; + if (stringValue) SPClear(stringValue); editSheetWillBeInitialized = NO; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 418a255f..9bef9d03 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -219,20 +219,20 @@ static NSUInteger SPSourceColumnTypeInteger = 1; - (void)dealloc { - if (mySQLConnection) [mySQLConnection release], mySQLConnection = nil; - if (sourcePath) [sourcePath release], sourcePath = nil; - if (fieldMappingTableColumnNames) [fieldMappingTableColumnNames release], fieldMappingTableColumnNames = nil; - if (defaultFieldTypesForComboBox) [defaultFieldTypesForComboBox release], defaultFieldTypesForComboBox = nil; - if (fieldMappingTableTypes) [fieldMappingTableTypes release], fieldMappingTableTypes = nil; - if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; - if (fieldMappingButtonOptions) [fieldMappingButtonOptions release], fieldMappingButtonOptions = nil; - if (fieldMappingOperatorOptions) [fieldMappingOperatorOptions release], fieldMappingOperatorOptions = nil; - if (fieldMappingOperatorArray) [fieldMappingOperatorArray release], fieldMappingOperatorArray = nil; - if (fieldMappingGlobalValues) [fieldMappingGlobalValues release], fieldMappingGlobalValues = nil; - if (fieldMappingGlobalValuesSQLMarked) [fieldMappingGlobalValuesSQLMarked release], fieldMappingGlobalValuesSQLMarked = nil; - if (fieldMappingTableDefaultValues) [fieldMappingTableDefaultValues release], fieldMappingTableDefaultValues = nil; - if (primaryKeyFields) [primaryKeyFields release], primaryKeyFields = nil; - if (toBeEditedRowIndexes) [toBeEditedRowIndexes release], toBeEditedRowIndexes = nil; + if (mySQLConnection) SPClear(mySQLConnection); + if (sourcePath) SPClear(sourcePath); + if (fieldMappingTableColumnNames) SPClear(fieldMappingTableColumnNames); + if (defaultFieldTypesForComboBox) SPClear(defaultFieldTypesForComboBox); + if (fieldMappingTableTypes) SPClear(fieldMappingTableTypes); + if (fieldMappingArray) SPClear(fieldMappingArray); + if (fieldMappingButtonOptions) SPClear(fieldMappingButtonOptions); + if (fieldMappingOperatorOptions) SPClear(fieldMappingOperatorOptions); + if (fieldMappingOperatorArray) SPClear(fieldMappingOperatorArray); + if (fieldMappingGlobalValues) SPClear(fieldMappingGlobalValues); + if (fieldMappingGlobalValuesSQLMarked) SPClear(fieldMappingGlobalValuesSQLMarked); + if (fieldMappingTableDefaultValues) SPClear(fieldMappingTableDefaultValues); + if (primaryKeyFields) SPClear(primaryKeyFields); + if (toBeEditedRowIndexes) SPClear(toBeEditedRowIndexes); [super dealloc]; } @@ -605,7 +605,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1; // Update the table view fieldMappingCurrentRow = 0; - if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; + if (fieldMappingArray) SPClear(fieldMappingArray); [self setupFieldMappingArray]; [rowDownButton setEnabled:NO]; [rowUpButton setEnabled:([fieldMappingImportArray count] > 1)]; @@ -912,7 +912,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1; // Update the table view fieldMappingCurrentRow = 0; - if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; + if (fieldMappingArray) SPClear(fieldMappingArray); [self setupFieldMappingArray]; [rowDownButton setEnabled:NO]; [rowUpButton setEnabled:([fieldMappingImportArray count] > 1)]; diff --git a/Source/SPGeneralPreferencePane.m b/Source/SPGeneralPreferencePane.m index 7879b9f0..a1c024e7 100644 --- a/Source/SPGeneralPreferencePane.m +++ b/Source/SPGeneralPreferencePane.m @@ -208,7 +208,7 @@ static NSString *SPDatabaseImage = @"database-small"; - (void)dealloc { - [folderImage release], folderImage = nil; + SPClear(folderImage); [super dealloc]; } diff --git a/Source/SPGotoDatabaseController.m b/Source/SPGotoDatabaseController.m index 3f9a4730..5e8a4fb2 100644 --- a/Source/SPGotoDatabaseController.m +++ b/Source/SPGotoDatabaseController.m @@ -265,8 +265,8 @@ - (void)dealloc { - [unfilteredList release], unfilteredList = nil; - [filteredList release], filteredList = nil; + SPClear(unfilteredList); + SPClear(filteredList); [super dealloc]; } diff --git a/Source/SPGroupNode.m b/Source/SPGroupNode.m index debc0b84..4d90c0c1 100644 --- a/Source/SPGroupNode.m +++ b/Source/SPGroupNode.m @@ -108,7 +108,7 @@ static NSString *SPGroupNodeIsExpandedKey = @"SPGroupNodeIsExpanded"; - (void)dealloc { - if (nodeName) [nodeName release], nodeName = nil; + if (nodeName) SPClear(nodeName); [super dealloc]; } diff --git a/Source/SPGrowlController.m b/Source/SPGrowlController.m index f363208c..be659041 100644 --- a/Source/SPGrowlController.m +++ b/Source/SPGrowlController.m @@ -143,7 +143,7 @@ static SPGrowlController *sharedGrowlController = nil; postNotification = YES; } - [timingNotificationName release], timingNotificationName = nil; + SPClear(timingNotificationName); } // Post notification only if preference is set and visibility has been confirmed @@ -192,7 +192,7 @@ static SPGrowlController *sharedGrowlController = nil; - (void)setVisibilityForNotificationName:(NSString *)name { if (timingNotificationName) { - [timingNotificationName release], timingNotificationName = nil; + SPClear(timingNotificationName); } timingNotificationName = [[NSString alloc] initWithString:name]; diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index 7236a977..5cca12f9 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -219,7 +219,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; // If no initial field has been selected yet - all fields are indexed - add the first field. if (!initialField) initialField = [fields objectAtIndex:0]; - if (indexedFieldNames) [indexedFieldNames release], indexedFieldNames = nil; + if (indexedFieldNames) SPClear(indexedFieldNames); // Reset the indexed columns [indexedFields removeAllObjects]; @@ -1081,14 +1081,14 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; - (void)dealloc { - [table release], table = nil; - [indexes release], indexes = nil; - [fields release], fields = nil; + SPClear(table); + SPClear(indexes); + SPClear(fields); - [supportsLength release], supportsLength = nil; - [requiresLength release], requiresLength = nil; + SPClear(supportsLength); + SPClear(requiresLength); - if (indexedFields) [indexedFields release], indexedFields = nil; + if (indexedFields) SPClear(indexedFields); #ifndef SP_CODA [prefs removeObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines]; diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 1b0128ca..cb1ba20b 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -206,7 +206,7 @@ [stateTimer invalidate]; [stateTimer release]; stateTimer = nil; - if(syncArrowImages) [syncArrowImages release], syncArrowImages = nil; + if(syncArrowImages) SPClear(syncArrowImages); [self performSelectorOnMainThread:@selector(reInvokeCompletion) withObject:nil waitUntilDone:YES]; closeMe = YES; return; diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index 07feee86..e4bdd1ec 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -560,7 +560,6 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte if([[item componentsSeparatedByString:SPUniqueSchemaDelimiter] count] < 4) [arr addObject:item]; } - if([arr count] < 1 ) @[@0, @""]; if([arr count] == 1) { NSArray *split = [[arr objectAtIndex:0] componentsSeparatedByString:SPUniqueSchemaDelimiter]; if([split count] == 2 ) [NSArray arrayWithObjects:@1, [split lastObject], nil]; diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index d28dfcb9..ae407312 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -232,7 +232,7 @@ - (void)dealloc { - [preferencePanes release], preferencePanes = nil; + SPClear(preferencePanes); [super dealloc]; } diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index f24a7891..5f8a422e 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -500,7 +500,7 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id"; { // If the filtered array is allocated and it's not a reference to the processes array get rid of it if ((processesFiltered) && (processesFiltered != processes)) { - [processesFiltered release], processesFiltered = nil; + SPClear(processesFiltered); } // Kill the auto refresh timer if running @@ -554,7 +554,7 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id"; // If the auto refresh timer is running, kill it if (autoRefreshTimer && [autoRefreshTimer isValid]) { [autoRefreshTimer invalidate]; - [autoRefreshTimer release], autoRefreshTimer = nil; + SPClear(autoRefreshTimer); } } @@ -710,7 +710,7 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id"; // If the filtered array is allocated and its not a reference to the processes array, // relase it to prevent memory leaks upon the next allocation. if ((processesFiltered) && (processesFiltered != processes)) { - [processesFiltered release], processesFiltered = nil; + SPClear(processesFiltered); } processesFiltered = [[NSMutableArray alloc] init]; @@ -763,9 +763,9 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id"; processListThreadRunning = NO; - [processes release], processes = nil; + SPClear(processes); - if (autoRefreshTimer) [autoRefreshTimer release], autoRefreshTimer = nil; + if (autoRefreshTimer) SPClear(autoRefreshTimer); [super dealloc]; } diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index c08aec3e..4aba3a14 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -645,20 +645,20 @@ static SPQueryController *sharedQueryController = nil; [NSObject cancelPreviousPerformRequestsWithTarget:self]; #ifndef SP_CODA - [dateFormatter release], dateFormatter = nil; + SPClear(dateFormatter); - [messagesFullSet release], messagesFullSet = nil; - [messagesFilteredSet release], messagesFilteredSet = nil; - [activeFilterString release], activeFilterString = nil; + SPClear(messagesFullSet); + SPClear(messagesFilteredSet); + SPClear(activeFilterString); - [favoritesContainer release], favoritesContainer = nil; - [historyContainer release], historyContainer = nil; - [contentFilterContainer release], contentFilterContainer = nil; + SPClear(favoritesContainer); + SPClear(historyContainer); + SPClear(contentFilterContainer); #endif - if (completionKeywordList) [completionKeywordList release], completionKeywordList = nil; - if (completionFunctionList) [completionFunctionList release], completionFunctionList = nil; - if (functionArgumentSnippets) [functionArgumentSnippets release], functionArgumentSnippets = nil; + if (completionKeywordList) SPClear(completionKeywordList); + if (completionFunctionList) SPClear(completionFunctionList); + if (functionArgumentSnippets) SPClear(functionArgumentSnippets); #ifndef SP_CODA pthread_mutex_destroy(&consoleLock); diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m index 9fd57e6d..f9dde93c 100644 --- a/Source/SPSQLExporter.m +++ b/Source/SPSQLExporter.m @@ -910,12 +910,12 @@ - (void)dealloc { - [sqlExportTables release], sqlExportTables = nil; - [sqlDatabaseHost release], sqlDatabaseHost = nil; - [sqlDatabaseName release], sqlDatabaseName = nil; - [sqlExportCurrentTable release], sqlExportCurrentTable = nil; - [sqlDatabaseVersion release], sqlDatabaseVersion = nil; - [sqlExportErrors release], sqlExportErrors = nil; + SPClear(sqlExportTables); + SPClear(sqlDatabaseHost); + SPClear(sqlDatabaseName); + SPClear(sqlExportCurrentTable); + SPClear(sqlDatabaseVersion); + SPClear(sqlExportErrors); [super dealloc]; } diff --git a/Source/SPSQLParser.m b/Source/SPSQLParser.m index d9162a66..a7a3ee98 100644 --- a/Source/SPSQLParser.m +++ b/Source/SPSQLParser.m @@ -1021,7 +1021,7 @@ TO_BUFFER_STATE to_scan_string (const char *); } - (void) setString:(NSString *)aString { [string setString:aString]; - if (delimiter) [delimiter release], delimiter = nil; + if (delimiter) SPClear(delimiter); delimiterLengthMinusOne = 0; lastMatchIsDelimiter = NO; [self _clearCharCache]; diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index 20f1aa43..c9a214ab 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -126,8 +126,8 @@ { // As this object is not a NSWindowController, use manual top-level nib item management - if (sshQuestionDialog) [sshQuestionDialog release], sshQuestionDialog = nil; - if (sshPasswordDialog) [sshPasswordDialog release], sshPasswordDialog = nil; + if (sshQuestionDialog) SPClear(sshQuestionDialog); + if (sshPasswordDialog) SPClear(sshPasswordDialog); parentWindow = theWindow; if (![NSBundle loadNibNamed:@"SSHQuestionDialog" owner:self]) { @@ -167,7 +167,7 @@ */ - (BOOL)setPasswordKeychainName:(NSString *)theName account:(NSString *)theAccount { - if (password) [password release], password = nil; + if (password) SPClear(password); passwordInKeychain = YES; keychainName = [[NSString alloc] initWithString:theName]; @@ -420,8 +420,8 @@ [task waitUntilExit]; // On tunnel close, clean up, ready for re-use if the delegate reconnects. - [task release], task = nil; - [standardError release], standardError = nil; + SPClear(task); + SPClear(standardError); [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSFileHandleDataAvailableNotification" object:nil]; @@ -438,8 +438,8 @@ // Run the run loop for a short time to ensure all task/pipe callbacks are dealt with [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]]; - [taskEnvironment release], taskEnvironment = nil; - [taskArguments release], taskArguments = nil; + SPClear(taskEnvironment); + SPClear(taskArguments); [pool release]; } @@ -647,7 +647,7 @@ NSString *thePassword = nil; if (requestedPassphrase) { thePassword = [NSString stringWithString:requestedPassphrase]; - [requestedPassphrase release], requestedPassphrase = nil; + SPClear(requestedPassphrase); } // Unlock the lock again @@ -747,8 +747,8 @@ if (identityFilePath) [identityFilePath release]; // As this object is not a NSWindowController, use manual top-level nib item management - if (sshQuestionDialog) [sshQuestionDialog release], sshQuestionDialog = nil; - if (sshPasswordDialog) [sshPasswordDialog release], sshPasswordDialog = nil; + if (sshQuestionDialog) SPClear(sshQuestionDialog); + if (sshPasswordDialog) SPClear(sshPasswordDialog); [super dealloc]; } diff --git a/Source/SPServerVariablesController.m b/Source/SPServerVariablesController.m index 090970fb..dade0687 100644 --- a/Source/SPServerVariablesController.m +++ b/Source/SPServerVariablesController.m @@ -115,7 +115,7 @@ // If the filtered array is allocated and it's not a reference to the processes array get rid of it if ((variablesFiltered) && (variablesFiltered != variables)) { - [variablesFiltered release], variablesFiltered = nil; + SPClear(variablesFiltered); } } @@ -292,7 +292,7 @@ // If the filtered array is allocated and its not a reference to the variables array // relase it to prevent memory leaks upon the next allocation. if ((variablesFiltered) && (variablesFiltered != variables)) { - [variablesFiltered release], variablesFiltered = nil; + SPClear(variablesFiltered); } variablesFiltered = [[NSMutableArray alloc] init]; @@ -381,7 +381,7 @@ { [prefs removeObserver:self forKeyPath:SPUseMonospacedFonts]; - [variables release], variables = nil; + SPClear(variables); [super dealloc]; } diff --git a/Source/SPSplitView.m b/Source/SPSplitView.m index 9d5b59d8..599432cf 100644 --- a/Source/SPSplitView.m +++ b/Source/SPSplitView.m @@ -108,8 +108,8 @@ [viewMinimumSizes release]; [viewMaximumSizes release]; - if (animationTimer) [animationTimer invalidate], [animationTimer release], animationTimer = nil; - if (animationRetainCycleBypassObject) [animationRetainCycleBypassObject release], animationRetainCycleBypassObject = nil; + if (animationTimer) [animationTimer invalidate], SPClear(animationTimer); + if (animationRetainCycleBypassObject) SPClear(animationRetainCycleBypassObject); [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; @@ -233,8 +233,8 @@ // Otherwise, start an animation. } else { - if (animationTimer) [animationTimer invalidate], [animationTimer release], animationTimer = nil; - if (animationRetainCycleBypassObject) [animationRetainCycleBypassObject release], animationRetainCycleBypassObject = nil; + if (animationTimer) [animationTimer invalidate], SPClear(animationTimer); + if (animationRetainCycleBypassObject) SPClear(animationRetainCycleBypassObject); animationStartTime = [NSDate monotonicTimeInterval]; // Determine the animation length, in seconds, starting with a quarter of a second @@ -853,8 +853,8 @@ // If the animation has reached the end, ensure completion tasks are run if (animationProgress == 1) { - if (animationTimer) [animationTimer invalidate], [animationTimer release], animationTimer = nil; - if (animationRetainCycleBypassObject) [animationRetainCycleBypassObject release], animationRetainCycleBypassObject = nil; + if (animationTimer) [animationTimer invalidate], SPClear(animationTimer); + if (animationRetainCycleBypassObject) SPClear(animationRetainCycleBypassObject); // If uncollapsing, restore the original view and remove the helper if (!collapsibleSubviewCollapsed) { @@ -1132,12 +1132,12 @@ [[wrappedView window] makeFirstResponder:firstResponderToRestore]; } - [wrappedView release], wrappedView = nil; + SPClear(wrappedView); } - (void)dealloc { - if (wrappedView) [wrappedView release], wrappedView = nil; + if (wrappedView) SPClear(wrappedView); [super dealloc]; } diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index d904ab73..b0d0f03c 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -407,7 +407,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper #endif // Reset table key store for use in argumentForRow: - if (keys) [keys release], keys = nil; + if (keys) SPClear(keys); // Reset data column store [dataColumns removeAllObjects]; @@ -425,7 +425,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Otherwise store the newly selected table name and reset the data } else { - if (selectedTable) [selectedTable release], selectedTable = nil; + if (selectedTable) SPClear(selectedTable); if (newTableName) selectedTable = [[NSString alloc] initWithString:newTableName]; previousTableRowsCount = 0; contentPage = 1; @@ -1509,7 +1509,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // If a string was supplied, use a custom query from that URL scheme else if([sender isKindOfClass:[NSString class]] && [(NSString *)sender length]) { - if(schemeFilter) [schemeFilter release], schemeFilter = nil; + if(schemeFilter) SPClear(schemeFilter); schemeFilter = [sender retain]; activeFilter = 2; } @@ -3942,7 +3942,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (void) setSortColumnNameToRestore:(NSString *)theSortColumnName isAscending:(BOOL)isAscending { - if (sortColumnToRestore) [sortColumnToRestore release], sortColumnToRestore = nil; + if (sortColumnToRestore) SPClear(sortColumnToRestore); if (theSortColumnName) { sortColumnToRestore = [[NSString alloc] initWithString:theSortColumnName]; @@ -3963,7 +3963,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (void) setSelectionToRestore:(NSDictionary *)theSelection { - if (selectionToRestore) [selectionToRestore release], selectionToRestore = nil; + if (selectionToRestore) SPClear(selectionToRestore); if (theSelection) selectionToRestore = [theSelection copy]; } @@ -3981,11 +3981,11 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (void) setFiltersToRestore:(NSDictionary *)filterSettings { - if (filterFieldToRestore) [filterFieldToRestore release], filterFieldToRestore = nil; - if (filterComparisonToRestore) [filterComparisonToRestore release], filterComparisonToRestore = nil; - if (filterValueToRestore) [filterValueToRestore release], filterValueToRestore = nil; - if (firstBetweenValueToRestore) [firstBetweenValueToRestore release], firstBetweenValueToRestore = nil; - if (secondBetweenValueToRestore) [secondBetweenValueToRestore release], secondBetweenValueToRestore = nil; + if (filterFieldToRestore) SPClear(filterFieldToRestore); + if (filterComparisonToRestore) SPClear(filterComparisonToRestore); + if (filterValueToRestore) SPClear(filterValueToRestore); + if (firstBetweenValueToRestore) SPClear(firstBetweenValueToRestore); + if (secondBetweenValueToRestore) SPClear(secondBetweenValueToRestore); if (filterSettings) { if ([filterSettings objectForKey:@"filterField"]) @@ -4311,7 +4311,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [NSObject cancelPreviousPerformRequestsWithTarget:self]; [NSObject cancelPreviousPerformRequestsWithTarget:tableContentView]; - if(fieldEditor) [fieldEditor release], fieldEditor = nil; + if(fieldEditor) SPClear(fieldEditor); [self clearTableLoadTimer]; [tableLoadingCondition release]; diff --git a/Source/SPTableContentDelegate.m b/Source/SPTableContentDelegate.m index 0a624efc..b73282ec 100644 --- a/Source/SPTableContentDelegate.m +++ b/Source/SPTableContentDelegate.m @@ -295,7 +295,7 @@ fieldEncoding = [columnDefinition objectForKey:@"charset_name"]; } - if (fieldEditor) [fieldEditor release], fieldEditor = nil; + if (fieldEditor) SPClear(fieldEditor); fieldEditor = [[SPFieldEditorController alloc] init]; diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 0e340f49..86243956 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -520,7 +520,7 @@ // connection reconnect dialog to appear and the user chose to close the connection. if (!syntaxResult) return nil; - if (tableCreateSyntax != nil) [tableCreateSyntax release], tableCreateSyntax = nil; + if (tableCreateSyntax != nil) SPClear(tableCreateSyntax); // A NULL value indicates that the user does not have permission to view the syntax if ([[syntaxResult objectAtIndex:1] isNSNull]) { @@ -864,7 +864,7 @@ } // Retrieve the table syntax string - if (tableCreateSyntax) [tableCreateSyntax release], tableCreateSyntax = nil; + if (tableCreateSyntax) SPClear(tableCreateSyntax); NSString *syntaxString = [[theResult getRowAsArray] objectAtIndex:1]; // A NULL value indicates that the user does not have permission to view the syntax @@ -1086,7 +1086,7 @@ nil, nil, [NSApp mainWindow], self, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving the trigger information for table '%@'. Please try again.\n\nMySQL said: %@", @"error retrieving table information informative message"), [tableListInstance tableName], [mySQLConnection lastErrorMessage]]); - if (triggers) [triggers release], triggers = nil; + if (triggers) SPClear(triggers); if (changeEncoding) [mySQLConnection restoreStoredEncoding]; } diff --git a/Source/SPTableFieldValidation.m b/Source/SPTableFieldValidation.m index e3c7f706..97c55a93 100644 --- a/Source/SPTableFieldValidation.m +++ b/Source/SPTableFieldValidation.m @@ -136,7 +136,7 @@ - (void)dealloc { - [fieldTypes release], fieldTypes = nil; + SPClear(fieldTypes); [super dealloc]; } diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index f82dd3e7..2374ea81 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -666,8 +666,8 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; [[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:SPUseMonospacedFonts]; - [relationData release], relationData = nil; - [takenConstraintNames release], takenConstraintNames = nil; + SPClear(relationData); + SPClear(takenConstraintNames); [super dealloc]; } diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index 9013fb05..77e5c77b 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -1479,7 +1479,7 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey"; [typeSuggestions release]; [extraFieldSuggestions release]; - [fieldValidation release], fieldValidation = nil; + SPClear(fieldValidation); if (defaultValues) [defaultValues release]; if (selectedTable) [selectedTable release]; diff --git a/Source/SPTableStructureLoading.m b/Source/SPTableStructureLoading.m index a15d31cd..1950c32e 100644 --- a/Source/SPTableStructureLoading.m +++ b/Source/SPTableStructureLoading.m @@ -312,7 +312,7 @@ ![tableDocumentInstance isWorking]; // Update the selected table name - if (selectedTable) [selectedTable release], selectedTable = nil; + if (selectedTable) SPClear(selectedTable); if (newTableName) selectedTable = [[NSString alloc] initWithString:newTableName]; [indexesController setTable:selectedTable]; @@ -348,7 +348,7 @@ [indexesController setFields:tableFields]; [indexesController setIndexes:[tableDetails objectForKey:@"tableIndexes"]]; - if (defaultValues) [defaultValues release], defaultValues = nil; + if (defaultValues) SPClear(defaultValues); newDefaultValues = [NSMutableDictionary dictionaryWithCapacity:[tableFields count]]; diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m index 1ab39825..179e509e 100644 --- a/Source/SPTableTriggers.m +++ b/Source/SPTableTriggers.m @@ -632,8 +632,8 @@ static const NSString *SPTriggerSQLMode = @"TriggerSQLMode"; - (void)dealloc { - [triggerData release], triggerData = nil; - [editedTrigger release], editedTrigger = nil; + SPClear(triggerData); + SPClear(editedTrigger); [[NSNotificationCenter defaultCenter] removeObserver:self]; [prefs removeObserver:self forKeyPath:SPUseMonospacedFonts]; diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 3efc45ef..147aec52 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -1314,7 +1314,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; - (NSMutableArray *)_allSchemaObjectsOfType:(SPTableType)type { NSMutableArray *returnArray = [NSMutableArray array]; - NSUInteger i; + NSInteger i; NSInteger cnt = [[self tables] count]; for(i=0; i<cnt; i++) { if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == type) @@ -1680,7 +1680,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [tableInfoInstance tableChanged:nil]; } - if (selectedTableName) [selectedTableName release], selectedTableName = nil; + if (selectedTableName) SPClear(selectedTableName); selectedTableType = SPTableTypeNone; @@ -1703,7 +1703,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // Save existing scroll position and details [spHistoryControllerInstance updateHistoryEntries]; - if (selectedTableName) [selectedTableName release], selectedTableName = nil; + if (selectedTableName) SPClear(selectedTableName); selectedTableName = [[NSString alloc] initWithString:newName]; selectedTableType = newType; @@ -1957,7 +1957,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // Don't try and maintain selections of multiple rows through filtering if ([tablesListView numberOfSelectedRows] > 1) { [tablesListView deselectAll:self]; - if (selectedTableName) [selectedTableName release], selectedTableName = nil; + if (selectedTableName) SPClear(selectedTableName); } #ifndef SP_CODA diff --git a/Source/SPThreadAdditions.m b/Source/SPThreadAdditions.m index 74476888..f61b6289 100644 --- a/Source/SPThreadAdditions.m +++ b/Source/SPThreadAdditions.m @@ -88,9 +88,9 @@ - (void)dealloc { - [object release], object = nil; + SPClear(object); selector = NULL; - [name release], name = nil; + SPClear(name); [super dealloc]; } diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index abfac606..bf78ab6f 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -848,7 +848,7 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; - (void)_clearData { [managedObjectContext reset]; - [managedObjectContext release], managedObjectContext = nil; + SPClear(managedObjectContext); } /** @@ -1458,18 +1458,20 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [managedObjectContext release]; - [persistentStoreCoordinator release]; - [managedObjectModel release]; - [privColumnToGrantMap release]; - [connection release]; - [privsSupportedByServer release]; - [schemas release]; - [availablePrivs release]; - [grantedSchemaPrivs release]; - [treeSortDescriptor release]; - [serverSupport release]; + + + SPClear(managedObjectContext); + SPClear(persistentStoreCoordinator); + SPClear(managedObjectModel); + SPClear(privColumnToGrantMap); + SPClear(connection); + SPClear(privsSupportedByServer); + SPClear(schemas); + SPClear(availablePrivs); + SPClear(grantedSchemaPrivs); + SPClear(treeSortDescriptor); + SPClear(treeSortDescriptors); + SPClear(serverSupport); [super dealloc]; } diff --git a/Source/SPXMLExporter.m b/Source/SPXMLExporter.m index 5aefd80b..dd4e9223 100644 --- a/Source/SPXMLExporter.m +++ b/Source/SPXMLExporter.m @@ -358,9 +358,9 @@ - (void)dealloc { - if (xmlDataArray) [xmlDataArray release], xmlDataArray = nil; - if (xmlTableName) [xmlTableName release], xmlTableName = nil; - if (xmlNULLString) [xmlNULLString release], xmlNULLString = nil; + if (xmlDataArray) SPClear(xmlDataArray); + if (xmlTableName) SPClear(xmlTableName); + if (xmlNULLString) SPClear(xmlNULLString); [super dealloc]; } |