Permalink
Browse files

Attempt at fixing a crash when trying to open the field editor sheet …

…and Accessibility Services are enabled and a certain other Application is running (issue #2220)
  • Loading branch information...
dmoagx committed Sep 10, 2015
1 parent 6f00eaa commit fe050dfb404ccd15d34ef46b27274545d05e9c58
Showing with 21 additions and 12 deletions.
  1. +9 −4 Source/SPCustomQuery.m
  2. +4 −4 Source/SPTableContent.m
  3. +8 −4 Source/SPTableContentDelegate.m
View
@@ -2441,6 +2441,12 @@ - (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn
// Check if the field can identified bijectively
if ( aTableView == customQueryView ) {
// Nothing is editable while the field editor is running.
// This guards against a special case where accessibility services might
// check if a table field is editable while the sheet is running.
if (fieldEditor) return NO;
NSDictionary *columnDefinition = [cqColumnDefinition objectAtIndex:[[aTableColumn identifier] integerValue]];
// Check if current field is a blob
@@ -2450,7 +2456,6 @@ - (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn
// Open the editing sheet if required
if ([customQueryView shouldUseFieldEditorForRow:rowIndex column:[[aTableColumn identifier] integerValue] checkWithLock:NULL])
{
if (fieldEditor) SPClear(fieldEditor);
fieldEditor = [[SPFieldEditorController alloc] init];
// Remember edited row for reselecting and setting the scroll view after reload
@@ -3681,9 +3686,9 @@ - (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo
}
}
if(fieldEditor) {
SPClear(fieldEditor);
}
// this is a delegate method of the field editor controller. calling release
// now would risk a dealloc while it is still our parent on the stack:
[fieldEditor autorelease], fieldEditor = nil;
// Preserve focus and restore selection indexes if appropriate
[[tableDocumentInstance parentWindow] makeFirstResponder:customQueryView];
View
@@ -3363,10 +3363,10 @@ - (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo
}
}
}
if(fieldEditor) {
SPClear(fieldEditor);
}
// this is a delegate method of the field editor controller. calling release
// now would risk a dealloc while it is still our parent on the stack:
[fieldEditor autorelease], fieldEditor = nil;
[[tableContentView window] makeFirstResponder:tableContentView];
@@ -235,6 +235,11 @@ - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn
#endif
if (tableView == tableContentView) {
// Nothing is editable while the field editor is running.
// This guards against a special case where accessibility services might
// check if a table field is editable while the sheet is running.
if (fieldEditor) return NO;
// Ensure that row is editable since it could contain "(not loaded)" columns together with
// issue that the table has no primary key
NSString *wherePart = [NSString stringWithString:[self argumentForRow:[tableContentView selectedRow]]];
@@ -303,8 +308,6 @@ - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn
fieldEncoding = [columnDefinition objectForKey:@"charset_name"];
}
if (fieldEditor) SPClear(fieldEditor);
fieldEditor = [[SPFieldEditorController alloc] init];
[fieldEditor setEditedFieldInfo:[NSDictionary dictionaryWithObjectsAndKeys:
@@ -709,8 +712,8 @@ - (void)controlTextDidChange:(NSNotification *)notification
/**
* If the user selected a table cell which is a blob field and tried to edit it
* cancel the fieldEditor, display the field editor sheet instead for editing
* and re-enable the fieldEditor after editing.
* cancel the inline edit, display the field editor sheet instead for editing
* and re-enable inline editing after closing the sheet.
*/
- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)aFieldEditor
{
@@ -767,6 +770,7 @@ - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)aFieldEdit
// Cancel editing
[control abortEditing];
NSAssert(fieldEditor == nil, @"Method should not to be called while a field editor sheet is open!");
// Call the field editor sheet
[self tableView:tableContentView shouldEditTableColumn:NSArrayObjectAtIndex([tableContentView tableColumns], column) row:row];

0 comments on commit fe050df

Please sign in to comment.