aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-07-15 00:23:13 +0000
committerrowanbeentje <rowan@beent.je>2009-07-15 00:23:13 +0000
commitaa2f8b4cbddb68b4aadd6544eb754c8468746633 (patch)
treecc4ca55dff6bcdda5480d7bb4d2fcdc16cb58517
parent0612652448f32e620a96e923a44b463fa1b9e0dc (diff)
downloadsequelpro-aa2f8b4cbddb68b4aadd6544eb754c8468746633.tar.gz
sequelpro-aa2f8b4cbddb68b4aadd6544eb754c8468746633.tar.bz2
sequelpro-aa2f8b4cbddb68b4aadd6544eb754c8468746633.zip
- Make the DBView window the document window. This allows the document to be closed when the window is closed, freeing the document's memory
- Update a number of dealloc methods to include more retained memory, and to avoid releasing non-retained memory - Remove notification observers and delegates where appropriate to avoid issues after document closing - Fix a couple of memory leaks - Support window cascading for all windows past the first, using the first window as the autosave window
-rw-r--r--Interfaces/English.lproj/DBView.xib12
-rw-r--r--Source/CMMCPConnection.m12
-rw-r--r--Source/CMTextView.m4
-rw-r--r--Source/NoodleLineNumberView.m11
-rw-r--r--Source/SPConnectionController.m4
-rw-r--r--Source/SPNarrowDownCompletion.m8
-rw-r--r--Source/SPPreferenceController.m4
-rw-r--r--Source/SPSSHTunnel.m2
-rw-r--r--Source/SPTableData.m5
-rw-r--r--Source/SPTableRelations.m1
-rw-r--r--Source/TableContent.m40
-rw-r--r--Source/TableDocument.m95
-rw-r--r--Source/TableDump.h2
-rw-r--r--Source/TableDump.m10
-rw-r--r--Source/TableSource.m3
15 files changed, 128 insertions, 85 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index da98edea..512e02bd 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -4328,7 +4328,7 @@
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMinSize">{780, 502}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
- <string key="NSFrameAutosaveName">DBView</string>
+ <string key="NSFrameAutosaveName"/>
</object>
<object class="NSWindowTemplate" id="554105051">
<int key="NSWindowStyleMask">1</int>
@@ -15076,6 +15076,14 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<int key="connectionID">6238</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">window</string>
+ <reference key="source" ref="427689665"/>
+ <reference key="destination" ref="207157706"/>
+ </object>
+ <int key="connectionID">6247</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -24636,7 +24644,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">6244</int>
+ <int key="maxID">6247</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index 0e3e085a..9848101e 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -320,7 +320,7 @@ static void forcePingTimeout(int signalNumber);
if (connectionTunnel) {
[connectionTunnel disconnect];
- [delegate setTitlebarStatus:@"SSH Disconnected"];
+ if (delegate) [delegate setTitlebarStatus:@"SSH Disconnected"];
//[delegate setStatusIconToImageWithName:@"ssh-disconnected"];
}
@@ -421,7 +421,7 @@ static void forcePingTimeout(int signalNumber);
if ([connectionTunnel state] != SPSSH_STATE_IDLE) [connectionTunnel disconnect];
[connectionTunnel connect];
- [delegate setTitlebarStatus:@"SSH Connecting…"];
+ if (delegate) [delegate setTitlebarStatus:@"SSH Connecting…"];
//[delegate setStatusIconToImageWithName:@"ssh-connecting"];
NSDate *tunnelStartDate = [NSDate date], *interfaceInteractionTimer;
@@ -429,14 +429,14 @@ static void forcePingTimeout(int signalNumber);
// Allow the tunnel to attempt to connect in a loop
while (1) {
if ([connectionTunnel state] == SPSSH_STATE_CONNECTED) {
- [delegate setTitlebarStatus:@"SSH Connected"];
+ if (delegate) [delegate setTitlebarStatus:@"SSH Connected"];
//[delegate setStatusIconToImageWithName:@"ssh-connected"];
connectionPort = [connectionTunnel localPort];
break;
}
if ([[NSDate date] timeIntervalSinceDate:tunnelStartDate] > (connectionTimeout + 1)) {
[connectionTunnel disconnect];
- [delegate setTitlebarStatus:@"SSH Disconnected"];
+ if (delegate) [delegate setTitlebarStatus:@"SSH Disconnected"];
//[delegate setStatusIconToImageWithName:@"ssh-disconnected"];
break;
}
@@ -704,7 +704,7 @@ static void forcePingTimeout(int signalNumber);
lastQueryErrorId = mysql_errno(mConnection);
if (connectionTunnel) {
[connectionTunnel disconnect];
- [delegate setTitlebarStatus:@"SSH Disconnected"];
+ if (delegate) [delegate setTitlebarStatus:@"SSH Disconnected"];
//[delegate setStatusIconToImageWithName:@"ssh-disconnected"];
}
return NO;
@@ -1347,6 +1347,8 @@ static void forcePingTimeout(int signalNumber)
- (void) dealloc
{
+ delegate = nil;
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
if (lastQueryErrorMessage) [lastQueryErrorMessage release];
if (connectionHost) [connectionHost release];
if (connectionLogin) [connectionLogin release];
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index c99baa1a..c8f62e56 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -270,7 +270,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[completionPopUp setCaretPos:pos];
[completionPopUp orderFront:self];
- //TODO : where to place the release??
+ // TODO: where to place the release??
// [completionPopUp release];
@@ -2591,6 +2591,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void) dealloc
{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [lineNumberView release];
[super dealloc];
}
diff --git a/Source/NoodleLineNumberView.m b/Source/NoodleLineNumberView.m
index 1743782b..f6626eb5 100644
--- a/Source/NoodleLineNumberView.m
+++ b/Source/NoodleLineNumberView.m
@@ -52,7 +52,9 @@
if ((self = [super initWithScrollView:aScrollView orientation:NSVerticalRuler]) != nil)
{
[self setClientView:[aScrollView documentView]];
- }
+ lineIndices = nil;
+ }
+
return self;
}
@@ -65,7 +67,7 @@
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
- [lineIndices release];
+ if (lineIndices) [lineIndices release];
[font release];
[super dealloc];
@@ -169,8 +171,7 @@
- (void)invalidateLineIndices
{
- [lineIndices release];
- lineIndices = nil;
+ if (lineIndices) [lineIndices release], lineIndices = nil;
}
- (void)textDidChange:(NSNotification *)notification
@@ -246,7 +247,7 @@
// TODO improve performance maybe via threading
if(stringLength>6000000)
return;
- [lineIndices release];
+ if (lineIndices) [lineIndices release];
lineIndices = [[NSMutableArray alloc] init];
index = 0;
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 2c5da3c7..8d09e0d5 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -117,9 +117,9 @@
{
[keychain release];
[prefs release];
- [favorites release];
+ if (favorites) [favorites release];
if (mySQLConnection) [mySQLConnection release];
- if (sshTunnel) [sshTunnel disconnect], [sshTunnel release];
+ if (sshTunnel) [sshTunnel setConnectionStateChangeSelector:nil delegate:nil], [sshTunnel disconnect], [sshTunnel release];
if (connectionKeychainItemName) [connectionKeychainItemName release];
if (connectionKeychainItemAccount) [connectionKeychainItemAccount release];
if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release];
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index 8b7b98ce..adadd902 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -96,6 +96,7 @@
mutablePrefix = [NSMutableString new];
textualInputCharacters = [[NSMutableCharacterSet alphanumericCharacterSet] retain];
caseSensitive = YES;
+ filtered = nil;
tableFont = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:@"CustomQueryEditorFont"]];
[self setupInterface];
@@ -109,9 +110,10 @@
[mutablePrefix release];
[textualInputCharacters release];
- [suggestions release];
+ // TODO: This may cause errors, I cannot see if it is always set up - only if !dictMode.
+ // [suggestions release];
- [filtered release];
+ if (filtered) [filtered release];
[super dealloc];
}
@@ -298,7 +300,7 @@
// so here we use the difference in height to find the new height for the window
// newHeight = [[self contentView] frame].size.height + (newHeight - [theTableView frame].size.height);
[self setFrame:NSMakeRect(old.x, old.y-newHeight, maxWidth, newHeight) display:YES];
- [filtered release];
+ if (filtered) [filtered release];
filtered = [newFiltered retain];
[theTableView reloadData];
}
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index 78d16a20..4a0d308e 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -61,7 +61,9 @@
if (self = [super initWithWindowNibName:@"Preferences"]) {
prefs = [NSUserDefaults standardUserDefaults];
[self applyRevisionChanges];
+
currentFavorite = nil;
+ keychain = nil;
}
return self;
@@ -958,7 +960,7 @@
// -------------------------------------------------------------------------------
- (void)dealloc
{
- [keychain release], keychain = nil;
+ if (keychain) [keychain release], keychain = nil;
if (currentFavorite) [currentFavorite release];
[super dealloc];
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m
index a0a3bdd7..62fc61b2 100644
--- a/Source/SPSSHTunnel.m
+++ b/Source/SPSSHTunnel.m
@@ -563,6 +563,8 @@
- (void)dealloc
{
+ delegate = nil;
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
if (connectionState != SPSSH_STATE_IDLE) [self disconnect];
[sshHost release];
[sshLogin release];
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index bcd0c2f6..888b8b11 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -929,8 +929,9 @@
[constraints release];
[status release];
- if (tableEncoding != nil) [tableEncoding release];
- if (tableCreateSyntax != nil) [tableCreateSyntax release];
+ if (tableEncoding) [tableEncoding release];
+ if (tableCreateSyntax) [tableCreateSyntax release];
+ if (mySQLConnection) [mySQLConnection release];
[super dealloc];
}
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index e2c5f23c..bb165710 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -323,6 +323,7 @@
- (void)dealloc
{
[relationData release], relationData = nil;
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 72f9dc22..4f519e5a 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -58,13 +58,15 @@
selectedTable = nil;
sortCol = nil;
lastField = nil;
+ editData = nil;
+ keys = nil;
areShowingAllRows = false;
currentlyEditingRow = -1;
prefs = [NSUserDefaults standardUserDefaults];
- usedQuery = [[NSString stringWithString:@""] retain];
+ usedQuery = [[NSString alloc] initWithString:@""];
}
return self;
@@ -101,8 +103,7 @@
selectedTable = aTable;
// Reset table key store for use in argumentForRow:
- if ( keys )
- keys = nil;
+ if (keys) [keys release], keys = nil;
// Restore the table content view to the top left
[tableContentView scrollRowToVisible:0];
@@ -709,9 +710,8 @@
- (void)setUsedQuery:(NSString *)query
{
- if(usedQuery)
- [usedQuery release];
- usedQuery = [[NSString stringWithString:query] retain];
+ if (usedQuery) [usedQuery release];
+ usedQuery = [[NSString alloc] initWithString:query];
}
@@ -955,7 +955,7 @@
[editSheet makeFirstResponder:editImage];
break;
case 2: // hex - load on demand
- if([editData length] && [[hexTextView string] isEqualToString:@""]) {
+ if(editData && [editData length] && [[hexTextView string] isEqualToString:@""]) {
[editSheetProgressBar startAnimation:self];
[hexTextView setString:[editData dataToFormattedHexString]];
[editSheetProgressBar stopAnimation:self];
@@ -1127,7 +1127,7 @@
image = [[[NSImage alloc] initWithPasteboard:[NSPasteboard generalPasteboard]] autorelease];
if (image) {
- if (nil != editData) [editData release];
+ if (editData) [editData release];
[editImage setImage:image];
@@ -1158,7 +1158,7 @@
editSheetWillBeInitialized = YES;
- if (nil != editData) [editData release];
+ if (editData) [editData release];
// If the image was not processed, set a blank string as the contents of the edit and hex views.
if ( data == nil ) {
@@ -1191,7 +1191,7 @@
// If the image was deleted, set a blank string as the contents of the edit and hex views.
// The actual dropped image processing is handled by processUpdatedImageData:.
if ( [editImage image] == nil ) {
- if (nil != editData) [editData release];
+ if (editData) [editData release];
editData = [[NSData alloc] init];
[editTextView setString:@""];
[hexTextView setString:@""];
@@ -1214,9 +1214,7 @@
[hexTextView setString:@""];
// free old data
- if ( editData != nil ) {
- [editData release];
- }
+ if ( editData ) [editData release];
// set edit data to text
editData = [[editTextView string] retain];
@@ -2305,6 +2303,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
theValue = [[filteredResult objectAtIndex:rowIndex] objectAtIndex:[[aTableColumn identifier] intValue]];
NSImage *image = nil;
+ if (editData) [editData release];
editData = [theValue retain];
// hide all views in editSheet
@@ -2340,7 +2339,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
[editTextScrollView setHidden:YES];
[editSheetSegmentControl setSelectedSegment:2];
} else {
- stringValue = [theValue retain];
+ stringValue = [[NSString alloc] initWithString:theValue];
[hexTextView setString:@""];
@@ -2409,15 +2408,13 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
currentlyEditingRow = rowIndex;
}
- [[filteredResult objectAtIndex:rowIndex] replaceObjectAtIndex:[[aTableColumn identifier] intValue] withObject:[editData copy]];
+ [[filteredResult objectAtIndex:rowIndex] replaceObjectAtIndex:[[aTableColumn identifier] intValue] withObject:[[editData copy] autorelease]];
// Clean up
[editImage setImage:nil];
[editTextView setString:@""];
[hexTextView setString:@""];
- if ( editData ) {
- [editData release];
- }
+ if ( editData ) [editData release], editData = nil;
}
return NO;
} else {
@@ -2580,13 +2577,12 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
// Last but not least
- (void)dealloc
-{
- [editData release];
+{
[fullResult release];
[filteredResult release];
- [keys release];
[oldRow release];
- [compareType release];
+ if (editData) [editData release];
+ if (keys) [keys release];
if (sortCol) [sortCol release];
if (lastField) [lastField release];
[usedQuery release];
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index cbcc13b7..a01c4ed4 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -59,12 +59,15 @@
{
if ((self = [super init])) {
- _encoding = [@"utf8" retain];
+ _encoding = [[NSString alloc] initWithString:@"utf8"];
_isConnected = NO;
chooseDatabaseButton = nil;
chooseDatabaseToolbarItem = nil;
connectionController = nil;
selectedDatabase = nil;
+ mySQLConnection = nil;
+ mySQLVersion = nil;
+ variables = nil;
printWebView = [[WebView alloc] init];
[printWebView setFrameLoadDelegate:self];
@@ -79,6 +82,17 @@
- (void)awakeFromNib
{
+ // The first window should use autosaving; subsequent windows should cascade
+ BOOL usedAutosave = [tableWindow setFrameAutosaveName:[self windowNibName]];
+ if (!usedAutosave) {
+ [tableWindow setFrameUsingName:[self windowNibName]];
+ NSArray *documents = [[NSDocumentController sharedDocumentController] documents];
+ NSRect previousFrame = [[[documents objectAtIndex:(([documents count] > 1)?[documents count]-2:[documents count]-1)] valueForKey:@"tableWindow"] frame];
+ NSPoint topLeftPoint = previousFrame.origin;
+ topLeftPoint.y += previousFrame.size.height;
+ [tableWindow setFrameTopLeftPoint:[tableWindow cascadeTopLeftFromPoint:topLeftPoint]];
+ }
+
// Set up the toolbar
[self setupToolbar];
@@ -110,9 +124,6 @@
av.size.height);
[titleAccessoryView setFrame:initialAccessoryViewFrame];
[windowFrame addSubview:titleAccessoryView];
-
- // Pull the new window to the front of the app
- [tableWindow makeKeyAndOrderFront:self];
}
#pragma mark -
@@ -140,17 +151,18 @@
// Get the mysql version
theResult = [mySQLConnection queryString:@"SHOW VARIABLES LIKE 'version'"];
version = [[theResult fetchRowAsArray] objectAtIndex:1];
+ if (mySQLVersion) [mySQLVersion release], mySQLVersion = nil;
if ( [version isKindOfClass:[NSData class]] ) {
// starting with MySQL 4.1.14 the mysql variables are returned as nsdata
mySQLVersion = [[NSString alloc] initWithData:version encoding:[mySQLConnection encoding]];
} else {
- mySQLVersion = [[NSString stringWithString:version] retain];
+ mySQLVersion = [[NSString alloc] initWithString:version];
}
// Update the selected database if appropriate
if ([connectionController database] && ![[connectionController database] isEqualToString:@""]) {
if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
- selectedDatabase = [[connectionController database] retain];
+ selectedDatabase = [[NSString alloc] initWithString:[connectionController database]];
}
// Update the database list
@@ -171,7 +183,6 @@
// Set the cutom query editor's MySQL version
[customQueryInstance setMySQLversion:mySQLVersion];
- [self setFileName:[NSString stringWithFormat:@"(MySQL %@) %@@%@ %@", mySQLVersion, [self user], [self host], [self database]]];
[tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], ([self database]?[self database]:@"")]];
[self viewStructure:self];
@@ -316,7 +327,7 @@
nil];
[connection release];
- [rows release];
+ if (rows) [rows release];
// Process the template and display the results.
NSString *result = [engine processTemplateInFileAtPath:templatePath withVariables:print_data];
@@ -395,9 +406,8 @@
}
//setConnection of TablesList and TablesDump to reload tables in db
- [selectedDatabase release];
- selectedDatabase = nil;
- selectedDatabase = [[chooseDatabaseButton titleOfSelectedItem] retain];
+ if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
+ selectedDatabase = [[NSString alloc] initWithString:[chooseDatabaseButton titleOfSelectedItem]];
[tablesListInstance setConnection:mySQLConnection];
[tableDumpInstance setConnection:mySQLConnection];
[tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], [self database]]];
@@ -463,9 +473,8 @@
}
//select new db
- [selectedDatabase release];
- selectedDatabase = nil;
- selectedDatabase = [[databaseNameField stringValue] retain];
+ if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
+ selectedDatabase = [[NSString alloc] initWithString:[databaseNameField stringValue]];
[self setDatabases:self];
[tablesListInstance setConnection:mySQLConnection];
[tableDumpInstance setConnection:mySQLConnection];
@@ -534,7 +543,7 @@
}
// db deleted with success
- selectedDatabase = nil;
+ if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
[self setDatabases:self];
[tablesListInstance setConnection:mySQLConnection];
[tableDumpInstance setConnection:mySQLConnection];
@@ -575,17 +584,13 @@
}
if(![dbName isKindOfClass:[NSNull class]]) {
if(![dbName isEqualToString:selectedDatabase]) {
- if (selectedDatabase) {
- [selectedDatabase release];
- selectedDatabase = nil;
- }
- selectedDatabase = [dbName retain];
+ if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
+ selectedDatabase = [[NSString alloc] initWithString:dbName];
[chooseDatabaseButton selectItemWithTitle:selectedDatabase];
[tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], selectedDatabase]];
}
} else {
- [selectedDatabase release];
- selectedDatabase = nil;
+ if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
[chooseDatabaseButton selectItemAtIndex:0];
[tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/", mySQLVersion, [self name]]];
}
@@ -654,8 +659,8 @@
if (_encodingViaLatin1)
[mySQLConnection queryString:@"SET CHARACTER_SET_RESULTS=latin1"];
[mySQLConnection setEncoding:[CMMCPConnection encodingForMySQLEncoding:[mysqlEncoding UTF8String]]];
- [_encoding autorelease];
- _encoding = [mysqlEncoding retain];
+ [_encoding release];
+ _encoding = [[NSString alloc] initWithString:mysqlEncoding];
} else {
[mySQLConnection queryString:[NSString stringWithFormat:@"SET NAMES '%@'", [self databaseEncoding]]];
_encodingViaLatin1 = NO;
@@ -926,7 +931,7 @@
id tableSyntax = [[theResult fetchRowAsArray] objectAtIndex:colOffs];
if ([tableSyntax isKindOfClass:[NSData class]])
- tableSyntax = [[NSString alloc] initWithData:tableSyntax encoding:[mySQLConnection encoding]];
+ tableSyntax = [[[NSString alloc] initWithData:tableSyntax encoding:[mySQLConnection encoding]] autorelease];
// copy to the clipboard
NSPasteboard *pb = [NSPasteboard generalPasteboard];
@@ -1654,7 +1659,7 @@
NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName ofType:@"png"];
if (!imagePath) return;
- NSImage *image = [[NSImage alloc] initByReferencingFile:imagePath];
+ NSImage *image = [[[NSImage alloc] initByReferencingFile:imagePath] autorelease];
[titleImageView setImage:image];
}
@@ -1950,10 +1955,10 @@
* Invoked when the document window is about to close
*/
- (void)windowWillClose:(NSNotification *)aNotification
-{
+{
+ [mySQLConnection setDelegate:nil];
if ([mySQLConnection isConnected]) [self closeConnection];
if ([[[SPQueryConsole sharedQueryConsole] window] isVisible]) [self toggleConsole:self];
- [[customQueryInstance helpWebViewWindow] release];
[createTableSyntaxWindow orderOut:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@@ -1970,6 +1975,26 @@
}
}
+/**
+ * Don't show the document "changed" dot in the close button, or show a
+ * "save?" dialog when closing the document.
+ */
+- (BOOL)isDocumentEdited
+{
+ return NO;
+}
+
+/**
+ * The window title for this document.
+ */
+- (NSString *)displayName
+{
+ if (!_isConnected) return @"Connecting...";
+
+ return [NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], ([self database]?[self database]:@"")];
+}
+
+
#pragma mark -
#pragma mark SMySQL delegate methods
@@ -2130,6 +2155,7 @@
if (theValue == nil) {
[[NSString alloc] initWithData:theValue encoding:NSASCIIStringEncoding];
}
+ if (theValue) [theValue autorelease];
}
return theValue;
@@ -2137,12 +2163,13 @@
- (void)dealloc
{
- [chooseDatabaseButton release];
- [mySQLConnection release];
- [variables release];
- [selectedDatabase release];
- [mySQLVersion release];
- [connectionController release];
+ [_encoding release];
+ [printWebView release];
+ if (connectionController) [connectionController release];
+ if (mySQLConnection) [mySQLConnection release];
+ if (variables) [variables release];
+ if (selectedDatabase) [selectedDatabase release];
+ if (mySQLVersion) [mySQLVersion release];
[allDatabases release];
[super dealloc];
}
diff --git a/Source/TableDump.h b/Source/TableDump.h
index d43912c3..01c502df 100644
--- a/Source/TableDump.h
+++ b/Source/TableDump.h
@@ -101,8 +101,6 @@
NSMutableArray *fieldMappingArray;
NSMutableArray *fieldMappingButtonOptions;
int currentRow;
- NSString *savePath;
- NSString *openPath;
NSUserDefaults *prefs;
BOOL progressCancelled;
}
diff --git a/Source/TableDump.m b/Source/TableDump.m
index a902e17b..94aa7a0a 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -735,7 +735,7 @@
//free arrays
if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil;
- importArray = nil;
+ [importArray release], importArray = nil;
}
// Import finished Growl notification
@@ -2324,6 +2324,8 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
tables = [[NSMutableArray alloc] init];
fieldMappingButtonOptions = [[NSMutableArray alloc] init];
fieldMappingArray = nil;
+ importArray = nil;
+ prefs = nil;
return self;
}
@@ -2331,12 +2333,10 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
- (void)dealloc
{
[tables release];
- [importArray release];
[fieldMappingButtonOptions release];
+ if (importArray) [importArray release];
if (fieldMappingArray) [fieldMappingArray release];
- [savePath release];
- [openPath release];
- [prefs release];
+ if (prefs) [prefs release];
[super dealloc];
}
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 9dcc571c..d44efe3c 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -1342,6 +1342,7 @@ traps enter and esc and make/cancel editing without entering next row
enumFields = [[NSMutableDictionary alloc] init];
currentlyEditingRow = -1;
+ defaultValues = nil;
prefs = [NSUserDefaults standardUserDefaults];
}
@@ -1361,8 +1362,8 @@ traps enter and esc and make/cancel editing without entering next row
[tableFields release];
[indexes release];
[oldRow release];
- [defaultValues release];
[enumFields release];
+ if (defaultValues) [defaultValues release];
[super dealloc];
}