From cf0ce7904972ba4144e1030c7b9331b119fc8f5d Mon Sep 17 00:00:00 2001 From: jakob Date: Mon, 19 Apr 2010 21:26:14 +0000 Subject: - more fixing of issue 641. I forgot to consider the case of deleting the last row in the table --- Source/TableContent.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Source') diff --git a/Source/TableContent.m b/Source/TableContent.m index d4676243..ec6b9ec8 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1402,7 +1402,7 @@ NSString *contextInfo = @"removerow"; - if (([tableContentView numberOfSelectedRows] == [tableContentView numberOfRows]) && !isFiltered && !isLimited && !isInterruptedLoad) { + if (([tableContentView numberOfSelectedRows] == [tableContentView numberOfRows]) && !isFiltered && !isLimited && !isInterruptedLoad && !isEditingNewRow) { contextInfo = @"removeallrows"; @@ -2164,8 +2164,17 @@ currentlyEditingRow = -1; } [tableContentView reloadData]; - } else if ( [contextInfo isEqualToString:@"removeallrows"] ) { + } else if ( [contextInfo isEqualToString:@"removeallrows"] ) { if ( returnCode == NSAlertDefaultReturn ) { + //check if the user is currently editing a row + if (isEditingRow) { + //cancel the edit + isEditingRow = NO; + // in case the delete fails, make sure we at least stay in a somewhat consistent state + [tableValues replaceRowAtIndex:currentlyEditingRow withRowContents:oldRow]; + currentlyEditingRow = -1; + } + [mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@", [selectedTable backtickQuotedString]]]; if ( ![mySQLConnection queryErrored] ) { -- cgit v1.2.3