diff options
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 25 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h | 3 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.m | 50 | ||||
-rw-r--r-- | Frameworks/MCPKit/MySQL/include/mysql.h | 3 | ||||
-rw-r--r-- | Frameworks/MCPKit/MySQL/include/mysql_com.h | 2 | ||||
-rw-r--r-- | Frameworks/MCPKit/MySQL/include/mysql_embed.h | 1 | ||||
-rw-r--r-- | Frameworks/MCPKit/MySQL/include/mysql_version.h | 4 | ||||
-rw-r--r-- | Frameworks/MCPKit/MySQL/lib/libmysqlclient.a | bin | 4561036 -> 4560292 bytes | |||
-rw-r--r-- | Frameworks/MCPKit/MySQL/lib/libmysqlclient_r.a | bin | 4595172 -> 4594252 bytes | |||
-rw-r--r-- | Frameworks/MCPKit/Support files/NSNotificationAdditions.h | 10 | ||||
-rw-r--r-- | Frameworks/MCPKit/Support files/NSNotificationAdditions.m | 78 | ||||
-rw-r--r-- | Source/SPCustomQuery.h | 8 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.h | 14 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.m | 52 | ||||
-rw-r--r-- | Source/SPKeychain.m | 2 | ||||
-rw-r--r-- | Source/SPTableData.m | 2 |
16 files changed, 163 insertions, 91 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 7efe4499..cf66a102 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -34,15 +34,14 @@ #import "MCPConnectionProxy.h" #import "MCPConnectionDelegate.h" #import "MCPStringAdditions.h" -#import "SPStringAdditions.h" -#import "RegexKitLite.h" +#import "RegexKitLite.h" // TODO: Remove along with queryDbStructureWithUserInfo #import "NSNotificationAdditions.h" #include <unistd.h> #include <mach/mach_time.h> #include <SystemConfiguration/SystemConfiguration.h> -const NSUInteger kMCPConnectionDefaultOption = CLIENT_COMPRESS | CLIENT_REMEMBER_OPTIONS | CLIENT_MULTI_RESULTS; +const NSUInteger kMCPConnectionDefaultOption = CLIENT_COMPRESS | CLIENT_REMEMBER_OPTIONS | CLIENT_MULTI_RESULTS | CLIENT_INTERACTIVE; const char *kMCPConnectionDefaultSocket = MYSQL_UNIX_ADDR; const char *kMCPSSLCipherList = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RSA-AES128-SHA:AES128-SHA:AES256-RMD:AES128-RMD:DES-CBC3-RMD:DHE-RSA-AES256-RMD:DHE-RSA-AES128-RMD:DHE-RSA-DES-CBC3-RMD:RC4-SHA:RC4-MD5:DES-CBC3-SHA:DES-CBC-SHA:EDH-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC-SHA"; const NSUInteger kMCPConnection_Not_Inited = 1000; @@ -166,7 +165,8 @@ static BOOL sTruncateLongFieldInLogs = YES; lastQueryErrorId = 0; lastQueryErrorMessage = nil; lastQueryAffectedRows = 0; - lastPingSuccess = NO; + lastPingSuccess = NO; + delegate = nil; delegateSupportsConnectionLostDecisions = NO; delegateResponseToWillQueryString = NO; @@ -525,7 +525,9 @@ static BOOL sTruncateLongFieldInLogs = YES; } while (![self tryLockConnection]); [self unlockConnection]; - if (mConnection->net.vio && mConnection->net.buff) mysql_close(mConnection); + // Only close the connection if it appears to still be active, and not reading or + // writing. This may result in a leak, but minimises crashes. + if (!mConnection->net.reading_or_writing && mConnection->net.vio && mConnection->net.buff) mysql_close(mConnection); mConnection = NULL; } @@ -580,6 +582,7 @@ static BOOL sTruncateLongFieldInLogs = YES; // Close the connection if it exists. if (mConnected) { + mConnected = NO; // Allow any pings or query cleanups to complete - within a time limit. uint64_t startTime_t, currentTime_t; @@ -594,11 +597,12 @@ static BOOL sTruncateLongFieldInLogs = YES; } while (![self tryLockConnection]); [self unlockConnection]; - if (mConnection->net.vio && mConnection->net.buff) mysql_close(mConnection); + // Only close the connection if it's not reading or writing - this may result + // in leaks, but minimises crashes. + if (!mConnection->net.reading_or_writing) mysql_close(mConnection); mConnection = NULL; } - mConnected = NO; isDisconnecting = NO; [self lockConnection]; @@ -2014,6 +2018,13 @@ void pingThreadCleanup(void *pingDetails) NSLog(@"Task cancelletion MySQL init failed."); } + // As the attempt may have taken up to the connection timeout, check lock status + // again, returning if nothing is required. + if ([self tryLockConnection]) { + [self unlockConnection]; + return; + } + // Reset the connection [self unlockConnection]; if (!isDisconnecting) [self reconnect]; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h b/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h index 36693703..bf57b789 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h @@ -40,4 +40,7 @@ static inline NSData *NSStringDataUsingLossyEncoding(NSString *self, NSInteger e @interface NSString (MCPStringAdditions) +- (NSString *)backtickQuotedString; +- (NSString *)tickQuotedString; + @end diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.m new file mode 100644 index 00000000..bd5b06cd --- /dev/null +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.m @@ -0,0 +1,50 @@ +// +// $Id$ +// +// MCPStringAdditions.m +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on March 25, 2010 +// Copyright (c) 2010 Stuart Connolly. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + + + +@implementation NSString (MCPStringAdditions) + +/** + * Returns the string quoted with backticks as required for MySQL identifiers + * eg.: tablename => `tablename` + * my`table => `my``table` + */ +- (NSString *)backtickQuotedString +{ + return [NSString stringWithFormat: @"`%@`", [self stringByReplacingOccurrencesOfString:@"`" withString:@"``"]]; +} + +/** + * Returns the string quoted with ticks as required for MySQL identifiers + * eg.: tablename => 'tablename' + * my'table => 'my''table' + */ +- (NSString *)tickQuotedString +{ + return [NSString stringWithFormat: @"'%@'", [self stringByReplacingOccurrencesOfString:@"'" withString:@"''"]]; +} + +@end diff --git a/Frameworks/MCPKit/MySQL/include/mysql.h b/Frameworks/MCPKit/MySQL/include/mysql.h index dcf3e167..699bd1f1 100644 --- a/Frameworks/MCPKit/MySQL/include/mysql.h +++ b/Frameworks/MCPKit/MySQL/include/mysql.h @@ -224,7 +224,8 @@ struct st_mysql_options { enum mysql_status { - MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT + MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT, + MYSQL_STATUS_STATEMENT_GET_RESULT }; enum mysql_protocol_type diff --git a/Frameworks/MCPKit/MySQL/include/mysql_com.h b/Frameworks/MCPKit/MySQL/include/mysql_com.h index 7d3dd3d4..357519d5 100644 --- a/Frameworks/MCPKit/MySQL/include/mysql_com.h +++ b/Frameworks/MCPKit/MySQL/include/mysql_com.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/Frameworks/MCPKit/MySQL/include/mysql_embed.h b/Frameworks/MCPKit/MySQL/include/mysql_embed.h index 4a7fd3ef..a7d6e610 100644 --- a/Frameworks/MCPKit/MySQL/include/mysql_embed.h +++ b/Frameworks/MCPKit/MySQL/include/mysql_embed.h @@ -20,7 +20,6 @@ /* Things we don't need in the embedded version of MySQL */ /* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */ -#undef HAVE_PSTACK /* No stacktrace */ #undef HAVE_OPENSSL #undef HAVE_SMEM /* No shared memory */ #undef HAVE_NDBCLUSTER_DB /* No NDB cluster */ diff --git a/Frameworks/MCPKit/MySQL/include/mysql_version.h b/Frameworks/MCPKit/MySQL/include/mysql_version.h index 736c2021..1eba2ede 100644 --- a/Frameworks/MCPKit/MySQL/include/mysql_version.h +++ b/Frameworks/MCPKit/MySQL/include/mysql_version.h @@ -9,11 +9,11 @@ #include <custom_conf.h> #else #define PROTOCOL_VERSION 10 -#define MYSQL_SERVER_VERSION "5.1.50" +#define MYSQL_SERVER_VERSION "5.1.57" #define MYSQL_BASE_VERSION "mysqld-5.1" #define MYSQL_SERVER_SUFFIX_DEF "" #define FRM_VER 6 -#define MYSQL_VERSION_ID 50150 +#define MYSQL_VERSION_ID 50157 #define MYSQL_PORT 3306 #define MYSQL_PORT_DEFAULT 0 #define MYSQL_UNIX_ADDR "/tmp/mysql.sock" diff --git a/Frameworks/MCPKit/MySQL/lib/libmysqlclient.a b/Frameworks/MCPKit/MySQL/lib/libmysqlclient.a Binary files differindex ab6939c1..969697fb 100644 --- a/Frameworks/MCPKit/MySQL/lib/libmysqlclient.a +++ b/Frameworks/MCPKit/MySQL/lib/libmysqlclient.a diff --git a/Frameworks/MCPKit/MySQL/lib/libmysqlclient_r.a b/Frameworks/MCPKit/MySQL/lib/libmysqlclient_r.a Binary files differindex b04f6c35..3c8d05fd 100644 --- a/Frameworks/MCPKit/MySQL/lib/libmysqlclient_r.a +++ b/Frameworks/MCPKit/MySQL/lib/libmysqlclient_r.a diff --git a/Frameworks/MCPKit/Support files/NSNotificationAdditions.h b/Frameworks/MCPKit/Support files/NSNotificationAdditions.h index 7d0d6f9a..82777ebb 100644 --- a/Frameworks/MCPKit/Support files/NSNotificationAdditions.h +++ b/Frameworks/MCPKit/Support files/NSNotificationAdditions.h @@ -25,11 +25,11 @@ @interface NSNotificationCenter (NSNotificationCenterAdditions) -- (void)postNotificationOnMainThread:(NSNotification *)notification; -- (void)postNotificationOnMainThread:(NSNotification *)notification waitUntilDone:(BOOL)wait; +- (void)postNotificationOnMainThread:(NSNotification *)aNotification; +- (void)postNotificationOnMainThread:(NSNotification *)aNotification waitUntilDone:(BOOL)shouldWaitUntilDone; -- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object; -- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo; -- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo waitUntilDone:(BOOL)wait; +- (void)postNotificationOnMainThreadWithName:(NSString *)aName object:(id)anObject; +- (void)postNotificationOnMainThreadWithName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo; +- (void)postNotificationOnMainThreadWithName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo waitUntilDone:(BOOL)shouldWaitUntilDone; @end diff --git a/Frameworks/MCPKit/Support files/NSNotificationAdditions.m b/Frameworks/MCPKit/Support files/NSNotificationAdditions.m index 9991c999..91b8134d 100644 --- a/Frameworks/MCPKit/Support files/NSNotificationAdditions.m +++ b/Frameworks/MCPKit/Support files/NSNotificationAdditions.m @@ -27,85 +27,71 @@ #import "pthread.h" @interface NSNotificationCenter (NSNotificationCenterAdditions_PrivateAPI) -+ (void)_postNotification:(NSNotification *)notification; -+ (void)_postNotificationName:(NSDictionary *)info; -+ (void)_postNotificationForwarder:(NSDictionary *)info; ++ (void)_postNotification:(NSNotification *)aNotification; ++ (void)_postNotificationWithDetails:(NSDictionary *)anInfoDictionary; @end @implementation NSNotificationCenter (NSNotificationCenterAdditions) -- (void)postNotificationOnMainThread:(NSNotification *)notification +- (void)postNotificationOnMainThread:(NSNotification *)aNotification { - if (pthread_main_np()) return [self postNotification:notification]; - - [self postNotificationOnMainThread:notification waitUntilDone:NO]; + if (pthread_main_np()) return [self postNotification:aNotification]; + + [self performSelectorOnMainThread:@selector(_postNotification:) withObject:aNotification waitUntilDone:NO]; } -- (void)postNotificationOnMainThread:(NSNotification *)notification waitUntilDone:(BOOL)shouldWaitUntilDone +- (void)postNotificationOnMainThread:(NSNotification *)aNotification waitUntilDone:(BOOL)shouldWaitUntilDone { - if (pthread_main_np()) return [self postNotification:notification]; - - [self performSelectorOnMainThread:@selector(_postNotification:) withObject:notification waitUntilDone:shouldWaitUntilDone]; + if (pthread_main_np()) return [self postNotification:aNotification]; + + [self performSelectorOnMainThread:@selector(_postNotification:) withObject:aNotification waitUntilDone:shouldWaitUntilDone]; } -- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object +- (void)postNotificationOnMainThreadWithName:(NSString *)aName object:(id)anObject { - if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:nil]; - - [self postNotificationOnMainThreadWithName:name object:object userInfo:nil waitUntilDone:NO]; + if (pthread_main_np()) return [self postNotificationName:aName object:anObject userInfo:nil]; + + [self postNotificationOnMainThreadWithName:aName object:anObject userInfo:nil waitUntilDone:NO]; } -- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo -{ - if(pthread_main_np()) return [self postNotificationName:name object:object userInfo:userInfo]; - - [self postNotificationOnMainThreadWithName:name object:object userInfo:userInfo waitUntilDone:NO]; +- (void)postNotificationOnMainThreadWithName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo +{ + if(pthread_main_np()) return [self postNotificationName:aName object:anObject userInfo:aUserInfo]; + + [self postNotificationOnMainThreadWithName:aName object:anObject userInfo:aUserInfo waitUntilDone:NO]; } -- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo waitUntilDone:(BOOL)shouldWaitUntilDone +- (void)postNotificationOnMainThreadWithName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo waitUntilDone:(BOOL)shouldWaitUntilDone { - if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:userInfo]; + if (pthread_main_np()) return [self postNotificationName:aName object:anObject userInfo:aUserInfo]; NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:3]; - - if (name) [info setObject:name forKey:@"name"]; - if (object) [info setObject:object forKey:@"object"]; - if (userInfo) [info setObject:userInfo forKey:@"userInfo"]; - [[self class] performSelectorOnMainThread:@selector(_postNotificationName:) withObject:info waitUntilDone:shouldWaitUntilDone]; + if (aName) [info setObject:aName forKey:@"name"]; + if (anObject) [info setObject:anObject forKey:@"object"]; + if (aUserInfo) [info setObject:aUserInfo forKey:@"userInfo"]; - [info release]; + [[self class] performSelectorOnMainThread:@selector(_postNotificationWithDetails:) withObject:info waitUntilDone:shouldWaitUntilDone]; } @end @implementation NSNotificationCenter (NSNotificationCenterAdditions_PrivateAPI) -+ (void)_postNotification:(NSNotification *)notification ++ (void)_postNotification:(NSNotification *)aNotification { - [[self defaultCenter] postNotification:notification]; + [[self defaultCenter] postNotification:aNotification]; } -+ (void)_postNotificationName:(NSDictionary *)info ++ (void)_postNotificationWithDetails:(NSDictionary *)anInfoDictionary { - NSString *name = [info objectForKey:@"name"]; - - id object = [info objectForKey:@"object"]; - - NSDictionary *userInfo = [info objectForKey:@"userInfo"]; + NSString *name = [anInfoDictionary objectForKey:@"name"]; + id object = [anInfoDictionary objectForKey:@"object"]; + NSDictionary *userInfo = [anInfoDictionary objectForKey:@"userInfo"]; [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; -} - -+ (void)_postNotificationForwarder:(NSDictionary *)info -{ - NSString *name = [info objectForKey:@"name"]; - - id object = [info objectForKey:@"object"]; - - NSDictionary *userInfo = [info objectForKey:@"userInfo"]; - [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; + [anInfoDictionary release]; } @end diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index f001d364..8d289f70 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -186,6 +186,14 @@ NSString *kCellEditorErrorTooManyMatches; } +#ifdef SP_REFACTOR +@property (assign) SPDatabaseDocument* tableDocumentInstance; +@property (assign) SPTablesList* tablesListInstance; +@property (assign) SPTextView *textView; +@property (assign) SPCopyTable *customQueryView; +@property (assign) NSButton* runAllButton; +#endif + @property(assign) BOOL textViewWasChanged; // IBAction methods diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index ebdac213..8f67ccc4 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -34,7 +34,7 @@ #ifndef SP_REFACTOR /* class forward decls */ SPProcessListController, SPServerVariablesController, SPUserManager, SPWindowController, #endif -SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPServerSupport; +SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPServerSupport, SPCustomQuery; #import "SPConnectionControllerDelegateProtocol.h" @@ -85,7 +85,7 @@ SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPServerSupport; IBOutlet id databaseCopySheet; IBOutlet id databaseRenameSheet; - IBOutlet id queryProgressBar; + IBOutlet NSProgressIndicator* queryProgressBar; IBOutlet NSBox *taskProgressLayer; IBOutlet id taskProgressIndicator; IBOutlet id taskDescriptionText; @@ -234,8 +234,9 @@ SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPServerSupport; } #ifdef SP_REFACTOR /* ivars */ -@property (readwrite, assign) id delegate; +@property (assign) id delegate; @property (readonly) NSMutableArray* allDatabases; +@property (assign) NSProgressIndicator* queryProgressBar; #endif #ifndef SP_REFACTOR /* ivars */ @@ -397,7 +398,9 @@ SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPServerSupport; // Tab methods - (void)makeKeyDocument; - (BOOL)parentTabShouldClose; +#endif - (void)parentTabDidClose; +#ifndef SP_REFACTOR - (void)willResignActiveTabInWindow; - (void)didBecomeActiveTabInWindow; - (void)tabDidBecomeKey; @@ -430,10 +433,11 @@ SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPServerSupport; - (void)connect; - (NSArray*)allTableNames; - (SPTablesList*)tablesListInstance; -- (SPTableData*)tableDataInstance; - (void)setTableSourceInstance:(SPTableStructure*)source; - (void)setTableContentInstance:(SPTableContent*)content; -- (void)setTableDataInstance:(SPTableData*)data; + +@property (assign) SPTableData* tableDataInstance; +@property (assign) SPCustomQuery* customQueryInstance; #endif @end diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 5a2bff92..7fb04a32 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -39,7 +39,9 @@ #import "ImageAndTextCell.h" #import "SPGrowlController.h" #import "SPExportController.h" +#endif #import "SPQueryController.h" +#ifndef SP_REFACTOR /* headers */ #import "SPWindowController.h" #endif #import "SPNavigatorController.h" @@ -76,10 +78,13 @@ #ifdef SP_REFACTOR /* headers */ #import "SPAlertSheets.h" #import "NSNotificationAdditions.h" +#import "SPCustomQuery.h" #endif // Constants +#ifndef SP_REFACTOR static NSString *SPCreateSyntx = @"SPCreateSyntax"; +#endif @interface SPDatabaseDocument () @@ -108,6 +113,9 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; #ifdef SP_REFACTOR /* ivars */ @synthesize allDatabases; @synthesize delegate; +@synthesize tableDataInstance; +@synthesize customQueryInstance; +@synthesize queryProgressBar; #endif - (id)init @@ -212,22 +220,12 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; tableContentInstance = content; } -- (void)setTableDataInstance:(SPTableData*)data -{ - tableDataInstance = data; -} - -- (SPTableData*)tableDataInstance -{ - return tableDataInstance; -} - #endif -#ifndef SP_REFACTOR /* awakeFromNib */ - (void)awakeFromNib { +#ifndef SP_REFACTOR if (_mainNibLoaded) return; _mainNibLoaded = YES; @@ -259,7 +257,7 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; // Register a second observer for when the logging preference changes so we can tell the current connection about it [prefs addObserver:self forKeyPath:SPConsoleEnableLogging options:NSKeyValueObservingOptionNew context:NULL]; - +#endif // Register for notifications [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willPerformQuery:) name:@"SMySQLQueryWillBePerformed" object:self]; @@ -268,6 +266,7 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"NSApplicationWillTerminateNotification" object:nil]; +#ifndef SP_REFACTOR // Find the Database -> Database Encoding menu (it's not in our nib, so we can't use interface builder) selectEncodingMenu = [[[[[NSApp mainMenu] itemWithTag:SPMainMenuDatabase] submenu] itemWithTag:1] submenu]; @@ -326,8 +325,8 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; [taskProgressWindow setContentView:taskProgressLayer]; [contentViewSplitter setDelegate:self]; -} #endif +} #ifndef SP_REFACTOR /* password sheet and history navigation */ /** @@ -444,10 +443,10 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; [tableDataInstance setConnection:mySQLConnection]; [extendedTableInfoInstance setConnection:mySQLConnection]; -#ifndef SP_REFACTOR /* update custom query editor */ // Set the custom query editor's MySQL version [customQueryInstance setMySQLversion:mySQLVersion]; +#ifndef SP_REFACTOR [self updateWindowTitle:self]; // Connected Growl notification @@ -2554,12 +2553,12 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; [queryProgressBar stopAnimation:self]; } -#ifndef SP_REFACTOR /* applicationWillTerminate: */ /** * Invoked when the application will terminate */ - (void)applicationWillTerminate:(NSNotification *)notification { +#ifndef SP_REFACTOR /* applicationWillTerminate: */ // Auto-save preferences to spf file based connection if([self fileURL] && [[[self fileURL] path] length] && ![self isUntitled]) @@ -2573,11 +2572,13 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; // Note that this call does not need to be removed in release builds as leaks analysis output is only // dumped if [[SPLogger logger] setDumpLeaksOnTermination]; has been called first. [[SPLogger logger] dumpLeaks]; +#endif } #pragma mark - #pragma mark Menu methods +#ifndef SP_REFACTOR /** * Saves SP session or if Custom Query tab is active the editor's content as SQL file * If sender == nil then the call came from [self writeSafelyToURL:ofType:forSaveOperation:error] @@ -3863,18 +3864,26 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; // Return YES by default return YES; } +#endif /** * Invoked when the parent tab is about to close */ - (void)parentTabDidClose { +<<<<<<< .working +======= +#ifndef SP_REFACTOR +>>>>>>> .merge-right.r3375 // Cancel autocompletion trigger if([prefs boolForKey:SPCustomQueryAutoComplete]) +#endif [NSObject cancelPreviousPerformRequestsWithTarget:[customQueryInstance valueForKeyPath:@"textView"] selector:@selector(doAutoCompletion) object:nil]; +#ifndef SP_REFACTOR if([prefs boolForKey:SPCustomQueryUpdateAutoHelp]) +#endif [NSObject cancelPreviousPerformRequestsWithTarget:[customQueryInstance valueForKeyPath:@"textView"] selector:@selector(autoHelp) object:nil]; @@ -3883,12 +3892,15 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; [mySQLConnection setDelegate:nil]; if (_isConnected) [self closeConnection]; else [connectionController cancelConnection]; +#ifndef SP_REFACTOR if ([[[SPQueryController sharedQueryController] window] isVisible]) [self toggleConsole:self]; +#endif [createTableSyntaxWindow orderOut:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self setParentWindow:nil]; } +#ifndef SP_REFACTOR /** * Invoked when the parent tab is currently the active tab in the * window, but is being switched away from, to allow cleaning up @@ -4114,7 +4126,8 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; [connection setObject:[connectionController sshHost] forKey:@"ssh_host"]; [connection setObject:[connectionController sshUser] forKey:@"ssh_user"]; [connection setObject:[NSNumber numberWithInt:[connectionController sshKeyLocationEnabled]] forKey:@"ssh_keyLocationEnabled"]; - [connection setObject:[connectionController sshKeyLocation] forKey:@"ssh_keyLocation"]; + if ([connectionController sshKeyLocation]) + [connection setObject:[connectionController sshKeyLocation] forKey:@"ssh_keyLocation"]; if ([connectionController sshPort] && [[connectionController sshPort] length]) [connection setObject:[NSNumber numberWithInteger:[[connectionController sshPort] integerValue]] forKey:@"ssh_port"]; break; @@ -4134,11 +4147,8 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; if (includePasswords) { NSString *pw = [self keychainPasswordForConnection:nil]; - if (![pw length]) pw = [connectionController password]; - if (pw) - [connection setObject:pw forKey:@"password"]; - else - [connection setObject:@"" forKey:@"password"]; + if (!pw) pw = [connectionController password]; + if (pw) [connection setObject:pw forKey:@"password"]; if ([connectionController type] == SPSSHTunnelConnection) { NSString *sshpw = [self keychainPasswordForSSHConnection:nil]; diff --git a/Source/SPKeychain.m b/Source/SPKeychain.m index bb010d3b..931f14d7 100644 --- a/Source/SPKeychain.m +++ b/Source/SPKeychain.m @@ -120,7 +120,7 @@ void *passwordData; UInt32 passwordLength; SecKeychainItemRef itemRef; - NSString *password = @""; + NSString *password = nil; // Check supplied variables and replaces nils with empty strings if (!name) name = @""; diff --git a/Source/SPTableData.m b/Source/SPTableData.m index de253e57..1936d0b1 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -928,7 +928,7 @@ BOOL changeEncoding = ![[mySQLConnection encoding] isEqualToString:@"utf8"]; // Catch unselected tables and return false - if ([[tableListInstance tableName] isEqualToString:@""] || ![tableListInstance tableName]) { + if (![tableListInstance tableName]) { pthread_mutex_unlock(&dataProcessingLock); return FALSE; } |