diff options
author | rowanbeentje <rowan@beent.je> | 2012-08-21 21:55:23 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-08-21 21:55:23 +0000 |
commit | a98a327e0e5d16df778920c1108df69f48ccd8c9 (patch) | |
tree | f155866c8ce23808386facee83b3894860504ef5 /Source/SPTableContent.m | |
parent | 0311db3d073af618f625b81c9bb5e7e06104ae5e (diff) | |
download | sequelpro-a98a327e0e5d16df778920c1108df69f48ccd8c9.tar.gz sequelpro-a98a327e0e5d16df778920c1108df69f48ccd8c9.tar.bz2 sequelpro-a98a327e0e5d16df778920c1108df69f48ccd8c9.zip |
- Alter table content endEditingFor calls to not be made if the undo manager is undoing or redoing, avoiding potential text processing loops when undoing in the search filter field (Issue #996)
- If the table is unfiltered, and the table filter field is cleared (eg when typing/changing) don't reload the table
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r-- | Source/SPTableContent.m | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 8b52958d..0c9f1d96 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -1503,7 +1503,10 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper NSString *taskString; if ([tableDocumentInstance isWorking]) return; + + // Check whether a save of the current row is required if (![self saveRowOnDeselect]) return; + #ifndef SP_REFACTOR [self setPaginationViewVisibility:FALSE]; #endif @@ -1523,10 +1526,18 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper if ([self tableFilterString]) { taskString = NSLocalizedString(@"Filtering table...", @"Filtering table task description"); - } else if (contentPage == 1) { - taskString = [NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTable]; } else { - taskString = [NSString stringWithFormat:NSLocalizedString(@"Loading page %lu...", @"Loading table page task string"), (unsigned long)contentPage]; + + // If the table isn't currently filtered, no action required. + if (!isFiltered) { + return; + } + + if (contentPage == 1) { + taskString = [NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTable]; + } else { + taskString = [NSString stringWithFormat:NSLocalizedString(@"Loading page %lu...", @"Loading table page task string"), (unsigned long)contentPage]; + } } [tableDocumentInstance startTaskWithDescription:taskString]; @@ -1541,9 +1552,6 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper { NSAutoreleasePool *filterPool = [[NSAutoreleasePool alloc] init]; - // Check whether a save of the current row is required. - if (![[self onMainThread] saveRowOnDeselect]) return; - #ifndef SP_REFACTOR // Update history [spHistoryControllerInstance updateHistoryEntries]; @@ -2953,7 +2961,13 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper if ( isEditingNewRow ) { #ifndef SP_REFACTOR if ( [prefs boolForKey:SPReloadAfterAddingRow] ) { - [[tableDocumentInstance parentWindow] endEditingFor:nil]; + + // Save any edits which have been started but not saved to the underlying table/data structures + // yet - but not if currently undoing/redoing, as this can cause a processing loop + if (![[[[tableContentView window] firstResponder] undoManager] isUndoing] && ![[[[tableContentView window] firstResponder] undoManager] isRedoing]) { + [[tableDocumentInstance parentWindow] endEditingFor:nil]; + } + previousTableRowsCount = tableRowsCount; [self loadTableValues]; } @@ -2976,7 +2990,13 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Reload table if set to - otherwise no action required. #ifndef SP_REFACTOR if ([prefs boolForKey:SPReloadAfterEditingRow]) { - [[tableDocumentInstance parentWindow] endEditingFor:nil]; + + // Save any edits which have been started but not saved to the underlying table/data structures + // yet - but not if currently undoing/redoing, as this can cause a processing loop + if (![[[[tableContentView window] firstResponder] undoManager] isUndoing] && ![[[[tableContentView window] firstResponder] undoManager] isRedoing]) { + [[tableDocumentInstance parentWindow] endEditingFor:nil]; + } + previousTableRowsCount = tableRowsCount; [self loadTableValues]; } @@ -3030,12 +3050,10 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper return YES; } - // 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. - if ([[[tableContentView window] firstResponder] respondsToSelector:@selector(delegate)] && - ![[(id)[[tableContentView window] firstResponder] delegate] isKindOfClass:[NSSearchField class]]) { - - [[tableContentView window] endEditingFor:nil]; + // Save any edits which have been started but not saved to the underlying table/data structures + // yet - but not if currently undoing/redoing, as this can cause a processing loop + if (![[[[tableContentView window] firstResponder] undoManager] isUndoing] && ![[[[tableContentView window] firstResponder] undoManager] isRedoing]) { + [[tableDocumentInstance parentWindow] endEditingFor:nil]; } // If no rows are currently being edited, or a save is in progress, return success at once. |