Skip to content

Commit dfcbabf

Browse files
committed
Fix a data corruption issue in custom query editor (fixes #2113)
... which occurred if ALL of the following conditions were met: * A cell of a custom query result was being edited * At the same time another process removed said row * The custom query was rerun without canceling or finishing the edit first (also added a NSBeep() for a certain tooltip error message)
1 parent 6afd525 commit dfcbabf

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

Source/SPCustomQuery.m

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ - (void)performQueries:(NSArray *)queries withCallback:(SEL)customQueryCallbackM
563563
{
564564
NSString *taskString;
565565

566+
//ensure there is no pending edit, which could be messed up (#2113)
567+
[[tableDocumentInstance parentWindow] endEditingFor:nil];
568+
566569
if ([queries count] > 1) {
567570
taskString = [NSString stringWithFormat:NSLocalizedString(@"Running query %i of %lu...", @"Running multiple queries string"), 1, (unsigned long)[queries count]];
568571
}
@@ -3822,27 +3825,31 @@ - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)aFieldEdit
38223825
pos.y -= 20;
38233826
switch(numberOfPossibleUpdateRows) {
38243827
case -1:
3825-
[SPTooltip showWithObject:kCellEditorErrorNoMultiTabDb
3826-
atLocation:pos
3827-
ofType:@"text"];
3828-
shouldBeginEditing = NO;
3828+
NSBeep();
3829+
[SPTooltip showWithObject:kCellEditorErrorNoMultiTabDb
3830+
atLocation:pos
3831+
ofType:@"text"];
3832+
shouldBeginEditing = NO;
38293833
break;
3834+
38303835
case 0:
3831-
[SPTooltip showWithObject:[NSString stringWithFormat:kCellEditorErrorNoMatch, [columnDefinition objectForKey:@"org_table"]]
3832-
atLocation:pos
3833-
ofType:@"text"];
3834-
shouldBeginEditing = NO;
3836+
NSBeep();
3837+
[SPTooltip showWithObject:[NSString stringWithFormat:kCellEditorErrorNoMatch, [columnDefinition objectForKey:@"org_table"]]
3838+
atLocation:pos
3839+
ofType:@"text"];
3840+
shouldBeginEditing = NO;
38353841
break;
38363842

38373843
case 1:
3838-
shouldBeginEditing = YES;
3844+
shouldBeginEditing = YES;
38393845
break;
38403846

38413847
default:
3842-
[SPTooltip showWithObject:[NSString stringWithFormat:kCellEditorErrorTooManyMatches, (long)numberOfPossibleUpdateRows]
3843-
atLocation:pos
3844-
ofType:@"text"];
3845-
shouldBeginEditing = NO;
3848+
NSBeep();
3849+
[SPTooltip showWithObject:[NSString stringWithFormat:kCellEditorErrorTooManyMatches, (long)numberOfPossibleUpdateRows]
3850+
atLocation:pos
3851+
ofType:@"text"];
3852+
shouldBeginEditing = NO;
38463853
}
38473854

38483855
isFieldEditable = shouldBeginEditing;

0 commit comments

Comments
 (0)