From 2aad505ec144b83123296c9bc4bad7c0e43753ef Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 26 Mar 2017 14:56:08 +0200 Subject: Fix an issue where the wrong table could be deleted when switching tables (by key press) fast enough after confirming deletion (#2742) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was caused by the delete code being called via a `performSelector:…` timer event instead of directly, which gave the run loop a chance to handle the key event between confirming the delete and actually executing it. --- Source/SPTablesList.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Source') diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index c9c60908..2fa26229 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -65,7 +65,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; @interface SPTablesList () -- (void)_removeTable:(NSNumber *)force; +- (void)_removeTable:(BOOL)force; - (void)_truncateTable; - (void)_addTable; - (void)_copyTable; @@ -730,9 +730,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; } else if ([contextInfo isEqualToString:SPRemoveTable]) { if (returnCode == NSAlertDefaultReturn) { - [self performSelector:@selector(_removeTable:) - withObject:[NSNumber numberWithInteger:[[(NSAlert *)sheet suppressionButton] state]] - afterDelay:0.0]; + [self _removeTable:([[(NSAlert *)sheet suppressionButton] state] == NSOnState)]; } } #ifndef SP_CODA @@ -2185,7 +2183,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; /** * Removes the selected object (table, view, procedure, function, etc.) from the database and tableView. */ -- (void)_removeTable:(NSNumber *)force +- (void)_removeTable:(BOOL)force { NSIndexSet *indexes = [tablesListView selectedRowIndexes]; @@ -2194,7 +2192,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // Get last index NSUInteger currentIndex = [indexes lastIndex]; - if ([force boolValue]) { + if (force) { [mySQLConnection queryString:@"SET FOREIGN_KEY_CHECKS = 0"]; } @@ -2274,7 +2272,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; } } - if ([force boolValue]) { + if (force) { [mySQLConnection queryString:@"SET FOREIGN_KEY_CHECKS = 1"]; } -- cgit v1.2.3