Skip to content

Commit 9fd78af

Browse files
committed
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)
1 parent ea39be5 commit 9fd78af

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Source/SPTableContentDelegate.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,12 @@ - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn
261261
[tableContentView reloadData];
262262
}
263263

264+
// Retrieve the column definition
265+
NSDictionary *columnDefinition = [cqColumnDefinition objectAtIndex:[[tableColumn identifier] integerValue]];
266+
264267
// Open the editing sheet if required
265268
if ([tableContentView shouldUseFieldEditorForRow:rowIndex column:[[tableColumn identifier] integerValue] checkWithLock:NULL]) {
266269

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

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

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

323325
NSInteger editedColumn = 0;
@@ -345,6 +347,13 @@ - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn
345347
return NO;
346348
}
347349

350+
// TODO: Fix editing of "Display as Hex" columns and remove this (also see above)
351+
if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"binary"] && [prefs boolForKey:SPDisplayBinaryDataAsHex]) {
352+
NSBeep();
353+
[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")];
354+
return NO;
355+
}
356+
348357
return YES;
349358
}
350359

0 commit comments

Comments
 (0)