Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSOutlineView: exception when edit a NSTextFieldCell bound to a NSTreeController

I get a crash when I edit a NSTextFieldCell (immediately after I click and the cursor starts to blink), in a NSOutlineView.

The table column is bound to the data source. The values are correctly displayed in the cell, the binding works, I get problems only when I edit the cell.

[theEditingColumn bind:@"value" myTreeController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", metadata.columnBindingKeyPath] options:bindingOptions];

This is the exception I get. It seems that the NSTextFieldCell is setting/getting values from the NSControllerTreeProxy rather than the content of the NSTreeController.

-[_NSControllerTreeProxy _valueForKeyPath:ofObjectAtIndex:]: unrecognized selector sent to instance 0x1ae0370
2015-07-16 11:20:55.008 [2647:735628] (
    0   CoreFoundation                      0x90e2bc63 __raiseError + 195
    1   libobjc.A.dylib                     0x9488fa2a objc_exception_throw + 276
    2   CoreFoundation                      0x90e307c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
    3   CoreFoundation                      0x90d66758 ___forwarding___ + 1032
    4   CoreFoundation                      0x90d6632e _CF_forwarding_prep_0 + 14
    5   AppKit                              0x9b9dd459 -[NSBinder _valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:] + 294
    6   AppKit                              0x9bd3e661 -[NSBinder valueForBinding:atIndex:resolveMarkersToPlaceholders:] + 461
    7   AppKit                              0x9c0c91a5 -[NSValueBinder _referenceBindingValueAtIndex:] + 56
    8   AppKit                              0x9bc382c7 -[_NSValueBinderPlugin editingHasBegun:] + 265
    9   AppKit                              0x9bc381ae -[NSValueBinder _startChanging] + 183
    10  AppKit                              0x9bc3802c -[NSTextValueBinder _startChanging] + 51
    11  AppKit                              0x9bc37ff4 -[NSValueBinder editorDidBeginEditing:] + 33
    12  AppKit                              0x9bc37fc4 -[_NSBindingAdaptor _editor:didChangeEditingState:bindingAdaptor:] + 166
    13  AppKit                              0x9bc37eec -[_NSBindingAdaptor editorDidBeginEditing:] + 218
    14  AppKit                              0x9c01ed24 -[NSTableView textShouldBeginEditing:] + 201
    15  AppKit                              0x9bb64be0 -[NSTextView(NSSharing) shouldChangeTextInRanges:replacementStrings:] + 310
    16  AppKit                              0x9bb64a9f -[NSTextView(NSSharing) shouldChangeTextInRange:replacementString:] + 121
    17  AppKit                              0x9c06c2c5 -[NSTextView(NSKeyBindingCommands) insertCompletion:forPartialWordRange:movement:isFinal:] + 513
    18  MyApp                               0x004de3d9 -[CBAutocompleteTextField insertCompletion:forPartialWordRange:movement:isFinal:] + 457
    19  AppKit                              0x9c070541 -[NSTextViewCompletionController _reflectSelection:] + 215
    20  AppKit                              0x9c0738b1 -[NSTextViewCompletionController tableViewSelectionDidChange:] + 41
    21  Foundation                          0x93eaa053 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 50
    22  CoreFoundation                      0x90de0c34 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
    23  CoreFoundation                      0x90cc0901 _CFXNotificationPost + 3713
    24  Foundation                          0x93e8b224 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
    25  Foundation                          0x93e9e772 -[NSNotificationCenter postNotificationName:object:] + 56
    26  AppKit                              0x9ba1ce87 -[NSTableView _sendSelectionChangedNotificationForRows:columns:] + 169
    27  AppKit                              0x9b9e94ff -[NSTableView _enableSelectionPostingAndPost] + 410
    28  AppKit                              0x9ba1c619 -[NSTableView _doSelectIndexes:byExtendingSelection:indexType:funnelThroughSingleIndexVersion:] + 3171
    29  AppKit                              0x9ba1b9a3 -[NSTableView selectRowIndexes:byExtendingSelection:] + 137
    30  AppKit                              0x9c072a7a -[NSTextViewCompletionController displayCompletions:indexOfSelectedItem:forPartialWordRange:originalString:atPoint:forTextView:] + 4794
    31  AppKit                              0x9c06c791 -[NSTextView(NSKeyBindingCommands) complete:] + 844
    32  libobjc.A.dylib                     0x9488d853 -[NSObject performSelector:withObject:] + 70
    33  AppKit                              0x9bb7baba -[NSResponder doCommandBySelector:] + 91
    34  AppKit                              0x9bb7b93e -[NSTextView doCommandBySelector:] + 152
    35  AppKit                              0x9bb7b887 -[NSTextInputContext(NSInputContext_WithCompletion) doCommandBySelector:completionHandler:] + 114
    36  AppKit                              0x9bb7b80b -[NSTextInputContext doCommandBySelector:] + 61
    37  AppKit                              0x9bb7b6e3 -[NSTextInputContext _handleCommand:] + 96
    38  AppKit                              0x9bb610c3 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 2336
    39  AppKit                              0x9c1e4b2d __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke1016 + 364
    40  AppKit                              0x9bb7b7ae __99-[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:]_block_invoke + 34
    41  AppKit                              0x9bb7b779 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_4 + 26
    42  AppKit                              0x9bb62f39 -[NSTextInputContext(NSInputContext_WithCompletion) hasMarkedTextWithCompletionHandler:] + 72
    43  AppKit                              0x9bb7b758 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_3 + 104
    44  AppKit                              0x9bb741fc -[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 107
    45  AppKit                              0x9c1e48e3 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke1004 + 322
    46  AppKit                              0x9c1e42a3 __125-[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:]_block_invoke + 33
    47  AppKit                              0x9c1e46da __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_2994 + 46
    48  HIToolbox                           0x9288ebd9 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_5 + 86
    49  HIToolbox                           0x9288eb71 __TryKeyDownEventToTSMKeyEvent_WithContinuationHandler_block_invoke + 32
    50  HIToolbox                           0x9288eb44 __TSMKeyEvent_WithCompletionHandler_block_invoke + 26
    51  HIToolbox                           0x9288ead1 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_3 + 50
    52  HIToolbox                           0x9288d518 __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke_2 + 57
    53  HIToolbox                           0x9288a37f __SendTSMEvent_WithCompletionHandler_block_invoke + 72
    54  HIToolbox                           0x9288d4ca __SendEventToEventTargetWithCompletionHandler_block_invoke + 25
    55  HIToolbox                           0x9288d49b ___ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec_block_invoke + 127
    56  AppKit                              0x9bb6f27c ___NSTSMEventHandler_block_invoke + 25
    57  AppKit                              0x9c1dd0a5 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke195 + 2676
    58  AppKit                              0x9bb62fee __102-[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:]_block_invoke + 34
    59  AppKit                              0x9bb62fb2 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_3 + 26
    60  AppKit                              0x9bb62f39 -[NSTextInputContext(NSInputContext_WithCompletion) hasMarkedTextWithCompletionHandler:] + 72
    61  AppKit                              0x9bb62ee1 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 104
    62  AppKit                              0x9bb62e3c -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 107
    63  AppKit                              0x9bb62ab5 -[NSTextInputContext handleTSMEvent:completionHandler:] + 3364
    64  AppKit                              0x9bb61d2b _NSTSMEventHandler + 302
    65  HIToolbox                           0x929ed5a4 _Z22_InvokeEventHandlerUPPP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvPFlS0_S2_S3_E + 36
    66  HIToolbox                           0x9282b681 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 2291
    67  HIToolbox                           0x9282a65c _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 402
    68  HIToolbox                           0x9282a4c3 SendEventToEventTargetWithOptions + 95
    69  HIToolbox                           0x92889ff9 SendTSMEvent_WithCompletionHandler + 451
    70  HIToolbox                           0x9288a6ee __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 569
    71  HIToolbox                           0x9288a49e __SendFilterTextEvent_WithCompletionHandler_block_invoke + 261
    72  HIToolbox                           0x9288a37f __SendTSMEvent_WithCompletionHandler_block_invoke + 72
    73  HIToolbox                           0x9288a061 SendTSMEvent_WithCompletionHandler + 555
    74  HIToolbox                           0x92889dfc SendFilterTextEvent_WithCompletionHandler + 283
    75  HIToolbox                           0x92889a04 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 398
    76  HIToolbox                           0x92889717 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 317
    77  HIToolbox                           0x92889592 __utDeliverTSMEvent_WithCompletionHandler_block_invoke + 465
    78  HIToolbox                           0x928893b8 TSMKeyEvent_WithCompletionHandler + 648
    79  HIToolbox                           0x928890d7 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 288
    80  HIToolbox                           0x92888f63 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 336
    81  HIToolbox                           0x92888cc9 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 261
    82  HIToolbox                           0x92888ab7 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 255
    83  HIToolbox                           0x9286e413 TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3730
    84  AppKit                              0x9c1e46a4 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke993 + 147
    85  AppKit                              0x9bb60652 -[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:] + 129
    86  AppKit                              0x9bb6031d -[NSTextInputContext _handleEvent:options:completionHandler:] + 1708
    87  AppKit                              0x9bb5fc4e -[NSTextInputContext handleEvent:] + 128
    88  AppKit                              0x9bb5fb4b -[NSView interpretKeyEvents:] + 205
    89  AppKit                              0x9bb5f989 -[NSTextView keyDown:] + 686
    90  MyApp                               0x004de011 -[CBAutocompleteTextField keyDown:] + 385
    91  AppKit                              0x9c0e7f9b -[NSWindow _reallySendEvent:isDelayedEvent:] + 8478
    92  AppKit                              0x9b9cb3ca -[NSWindow sendEvent:] + 526
    93  AppKit                              0x9b9c79c4 -[NSApplication sendEvent:] + 4765
    94  MyApp                                0x0004f2a2 -[CBApplication sendEvent:] + 370
    95  AppKit                              0x9b8e7bfc -[NSApplication run] + 1003
    96  AppKit                              0x9b85cfa0 NSApplicationMain + 2082
    97  MyApp                               0x000026fb main + 43
    98  MyApp                               0x00002605 start + 53

I guess the binding works well to display the values, but not for editing them?

UPDATE I've added a symbolic breakpoint and I get the following:

po  *(id *)($esp + 4)
<NSTextValueBinder: 0xfe40720>{object: <NSTableColumn: 0xfe40180>   identifier: MovieReleaseYear, bindings: value=arrangedObjects.MovieReleaseYear}

p  *(SEL *)($esp + 8)
(SEL) $10 = "_valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:"

po  *(id *)($esp + 12)
arrangedObjects

po  *(id *)($esp + 16)
<CBTreeController: 0x39b4340>[object class: NSMutableDictionary]
like image 537
aneuryzm Avatar asked Jul 16 '15 09:07

aneuryzm


1 Answers

I recently stumbled upon the same problem as you. I am unsure if it is to late to help you, but I will still provide what fixed it for me.

I don't know your entire code, so I can't be sure if it is the same issue as you, but I was, too, trying to bind a column and edit it later, giving me the same crash.

It is quite simple in fact. I was binding the column before adding it to the Outline view like such :

[theEditingColumn bind:@"value" myTreeController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", metadata.columnBindingKeyPath] options:bindingOptions];
[theOutlineView addTableColumn: theEditingColumn]

I can't give any explanation as to why this is the case, but switching it fixed it on my side :

[theOutlineView addTableColumn: theEditingColumn]
[theEditingColumn bind:@"value" myTreeController withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@", metadata.columnBindingKeyPath] options:bindingOptions];
like image 124
Xavier Avatar answered Oct 27 '22 22:10

Xavier