Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Disable editing columns in "Display in Hex" mode
This is a workaround for a potential data loss/corruption bug until we really fix this (see #1876)
  • Loading branch information
dmoagx committed Mar 24, 2015
1 parent ea39be5 commit 9fd78af
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Source/SPTableContentDelegate.m
Expand Up @@ -261,11 +261,12 @@ - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn
[tableContentView reloadData];
}

// Retrieve the column definition
NSDictionary *columnDefinition = [cqColumnDefinition objectAtIndex:[[tableColumn identifier] integerValue]];

// Open the editing sheet if required
if ([tableContentView shouldUseFieldEditorForRow:rowIndex column:[[tableColumn identifier] integerValue] checkWithLock:NULL]) {

// Retrieve the column definition
NSDictionary *columnDefinition = [cqColumnDefinition objectAtIndex:[[tableColumn identifier] integerValue]];
BOOL isBlob = [tableDataInstance columnIsBlobOrText:[[tableColumn headerCell] stringValue]];

// A table is per definition editable
Expand Down Expand Up @@ -318,6 +319,7 @@ - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn

if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"binary"] && [prefs boolForKey:SPDisplayBinaryDataAsHex]) {
[fieldEditor setTextMaxLength:[[self tableView:tableContentView objectValueForTableColumn:tableColumn row:rowIndex] length]];
isFieldEditable = NO;
}

NSInteger editedColumn = 0;
Expand Down Expand Up @@ -345,6 +347,13 @@ - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn
return NO;
}

// TODO: Fix editing of "Display as Hex" columns and remove this (also see above)
if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"binary"] && [prefs boolForKey:SPDisplayBinaryDataAsHex]) {
NSBeep();
[SPTooltip showWithObject:NSLocalizedString(@"Disable \"Display Binary Data as Hex\" in the View menu to edit this field.",@"Temporary : Tooltip shown when trying to edit a binary field in table content view while it is displayed using HEX conversion")];
return NO;
}

return YES;
}

Expand Down

0 comments on commit 9fd78af

Please sign in to comment.