Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Source/DocEditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ - (BOOL) saveDocument {
if (!_readOnly && _root && ![properties isEqual: _revision.properties]) {
CBLDocument* doc;
NSError* error;
if (_revision)
if (_revision && _revision.document)
doc = _revision.document;
else
doc = _db[properties[@"_id"]];
Expand Down Expand Up @@ -166,7 +166,7 @@ - (IBAction) addProperty: (id)sender {
} else {
parent = sibling.parent;
}

JSONItem *newItem = [parent createChildBefore: sibling];
if (!newItem) {
NSBeep();
Expand Down Expand Up @@ -266,8 +266,8 @@ - (void) enablePropertyButtons {


- (id) outlineView: (NSOutlineView *)outlineView
objectValueForTableColumn: (NSTableColumn *)tableColumn
byItem: (JSONItem*)item
objectValueForTableColumn: (NSTableColumn *)tableColumn
byItem: (JSONItem*)item
{
if ([tableColumn.identifier isEqualToString: @"key"]) {
return item.key;
Expand Down Expand Up @@ -311,8 +311,8 @@ - (void)outlineView: (NSOutlineView *)outlineView


- (BOOL)outlineView:(NSOutlineView *)outlineView
shouldEditTableColumn:(NSTableColumn *)tableColumn
item: (JSONItem*)item
shouldEditTableColumn:(NSTableColumn *)tableColumn
item: (JSONItem*)item
{
BOOL isKeyColumn = [tableColumn.identifier isEqualToString: @"key"];
if (_readOnly)
Expand Down Expand Up @@ -350,7 +350,7 @@ - (void) outlineView: (NSOutlineView*)outlineView
return;
if (item.isSpecial && !_untitled)
return;

if (newCellValue == nil || [newCellValue isEqual: @""]) {
// User entered empty key or value: delete property
JSONItem* parent = item.parent;
Expand All @@ -368,8 +368,8 @@ - (void) outlineView: (NSOutlineView*)outlineView


- (BOOL) control: (NSControl*)control
didFailToFormatString: (NSString*)string
errorDescription: (NSString*)errorMessage
didFailToFormatString: (NSString*)string
errorDescription: (NSString*)errorMessage
{
if (_cancelingEdit)
return YES;
Expand All @@ -382,9 +382,9 @@ - (BOOL) control: (NSControl*)control
[alert addButtonWithTitle: @"Cancel"];
[alert beginSheetModalForWindow: control.window
completionHandler:^(NSModalResponse returnCode) {
if (returnCode == NSAlertSecondButtonReturn)
[self cancelOperation: self];
}];
if (returnCode == NSAlertSecondButtonReturn)
[self cancelOperation: self];
}];
}
return NO;
}
Expand All @@ -397,7 +397,7 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification {

- (BOOL)control:(NSControl *)control
textView:(NSTextView *)textView
doCommandBySelector:(SEL)command
doCommandBySelector:(SEL)command
{
//NSLog(@"command: %@", NSStringFromSelector(command));
if (command == @selector(cancelOperation:)) { // Esc key
Expand Down