Skip to content
Permalink
Browse files

Fix an issue where the wrong table could be deleted when switching ta…

…bles (by key press) fast enough after confirming deletion (#2742)

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.
  • Loading branch information
dmoagx committed Mar 26, 2017
1 parent 430ff7b commit 2aad505ec144b83123296c9bc4bad7c0e43753ef
Showing with 5 additions and 7 deletions.
  1. +5 −7 Source/SPTablesList.m
@@ -65,7 +65,7 @@

@interface SPTablesList ()

- (void)_removeTable:(NSNumber *)force;
- (void)_removeTable:(BOOL)force;
- (void)_truncateTable;
- (void)_addTable;
- (void)_copyTable;
@@ -730,9 +730,7 @@ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSSt
}
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 @@ - (void)setDatabaseDocument:(SPDatabaseDocument*)val
/**
* 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 @@ - (void)_removeTable:(NSNumber *)force
// Get last index
NSUInteger currentIndex = [indexes lastIndex];

if ([force boolValue]) {
if (force) {
[mySQLConnection queryString:@"SET FOREIGN_KEY_CHECKS = 0"];
}

@@ -2274,7 +2272,7 @@ - (void)_removeTable:(NSNumber *)force
}
}

if ([force boolValue]) {
if (force) {
[mySQLConnection queryString:@"SET FOREIGN_KEY_CHECKS = 1"];
}

0 comments on commit 2aad505

Please sign in to comment.
You can’t perform that action at this time.