aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-03-21 01:03:06 +0000
committerrowanbeentje <rowan@beent.je>2011-03-21 01:03:06 +0000
commit07c0c28a885dd2f24596ffcbdca6c7c65f913833 (patch)
tree8dc75f8e0e6049f397921a5106ea9b40033189e8
parentd398680c63f87204a8b6ce2c34db1c494df22cca (diff)
downloadsequelpro-07c0c28a885dd2f24596ffcbdca6c7c65f913833.tar.gz
sequelpro-07c0c28a885dd2f24596ffcbdca6c7c65f913833.tar.bz2
sequelpro-07c0c28a885dd2f24596ffcbdca6c7c65f913833.zip
Address Issue #984:
- Fix potential reload loop when setTableDetails: deselects the table row, after the fields have been emptied but before any edits have been committed - Fix reload action not checking whether items need saving before comparisons occur - Save incomplete edits back to the table before processing changes to avoid changes requiring additional queries
-rw-r--r--Source/SPTableStructure.m15
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index 904e4517..aab62af8 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -203,7 +203,6 @@
}
NSMutableArray *theTableFields = [[NSMutableArray alloc] init];
- [theTableFields setArray:[NSArray array]];
// Make a mutable copy out of the cached [tableDataInstance columns] since we're adding infos
for (id col in [tableDataInstance columns])
@@ -352,6 +351,10 @@
*/
- (IBAction)reloadTable:(id)sender
{
+
+ // Check whether a save of the current row is required
+ if ( ![[self onMainThread] saveRowOnDeselect] ) return;
+
[tableDataInstance resetAllData];
[tableDocumentInstance setStatusRequiresReload:YES];
@@ -379,9 +382,9 @@
[indexesController setTable:selectedTable];
// Reset the table store and display
+ [tableSourceView deselectAll:self];
[tableFields removeAllObjects];
[enumFields removeAllObjects];
- [tableSourceView deselectAll:self];
[indexesTableView deselectAll:self];
[addFieldButton setEnabled:NO];
[copyFieldButton setEnabled:NO];
@@ -846,6 +849,14 @@
*/
- (BOOL)saveRowOnDeselect
{
+
+ // Save any edits which have been made but not saved to the table yet;
+ // but not for any NSSearchFields which could cause a crash for undo, redo.
+ id currentFirstResponder = [[tableDocumentInstance parentWindow] firstResponder];
+ if (currentFirstResponder && [currentFirstResponder isKindOfClass:[NSView class]] && [(NSView *)currentFirstResponder isDescendantOf:tableSourceView]) {
+ [[tableDocumentInstance parentWindow] endEditingFor:nil];
+ }
+
// If no rows are currently being edited, or a save is already in progress, return success at once.
if (!isEditingRow || isSavingRow) return YES;
isSavingRow = YES;