在我的应用程序中,我有一个NSOutlineview,它经常刷新,并且崩溃,得到下面的堆栈跟踪
Exception Name: NSInternalInconsistencyException
Description: (null) should not be expanded already!
User Info: (null)
0 CoreFoundation 0x00007fff918840a6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff96eef3f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff91883ee8 +[NSException raise:format:arguments:] + 104
3 Foundation 0x00007fff9769a6a2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
4 AppKit 0x00007fff933e19b0 -[NSOutlineView _expandItemEntry:expandChildren:startLevel:] + 1153
5 AppKit 0x00007fff933c7c42 -[NSOutlineView _uncachedNumberOfRows] + 379
6 AppKit 0x00007fff93401938 -[NSOutlineView frameOfCellAtColumn:row:] + 66
7 AppKit 0x00007fff9379f51c -[NSTableViewDynamicToolTipManager dynamicToolTipRectAtPoint:] + 298
8 AppKit 0x00007fff9385cb9a -[NSViewDynamicToolTipManager _markMovementTrackingInfo] + 142
9 AppKit 0x00007fff933f5d0a -[NSViewDynamicToolTipManager _restartMovementTracking] + 231
10 AppKit 0x00007fff933f5b8b -[NSViewDynamicToolTipManager _viewVisibleBoundsChanged] + 526
11 AppKit 0x00007fff933f58eb -[NSViewDynamicToolTipManager _threadsafeViewVisibleBoundsChanged] + 39
12 AppKit 0x00007fff9336cda7 -[NSView(NSInternal) _updateTrackingAreas] + 479
13 AppKit 0x00007fff933f6be8 -[NSOutlineView _updateTrackingAreas] + 99
14 CoreFoundation 0x00007fff9187ca46 __NSArrayEnumerate + 582
15 AppKit 0x00007fff9336d090 -[NSView(NSInternal) _updateTrackingAreas] + 1224
16 CoreFoundation 0x00007fff9187ca46 __NSArrayEnumerate + 582
17 AppKit 0x00007fff9336d090 -[NSView(NSInternal) _updateTrackingAreas] + 1224
18 AppKit 0x00007fff9336dded -[NSScrollView _updateTrackingAreas] + 122
19 CoreFoundation 0x00007fff9187ca46 __NSArrayEnumerate + 582
20 AppKit 0x00007fff9336d090 -[NSView(NSInternal) _updateTrackingAreas] + 1224
21 CoreFoundation 0x00007fff9187ca46 __NSArrayEnumerate + 582
22 AppKit 0x00007fff9336d090 -[NSView(NSInternal) _updateTrackingAreas] + 1224
23 CoreFoundation 0x00007fff9187ca46 __NSArrayEnumerate + 582
24 AppKit 0x00007fff9336d090 -[NSView(NSInternal) _updateTrackingAreas] + 1224
25 AppKit 0x00007fff9336caac _handleInvalidCursorRectsNote + 863
26 CoreFoundation 0x00007fff9184a9b7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
27 CoreFoundation 0x00007fff9184a921 __CFRunLoopDoObservers + 369
28 CoreFoundation 0x00007fff91825d88 __CFRunLoopRun + 728
29 CoreFoundation 0x00007fff918256b2 CFRunLoopRunSpecific + 290
30 HIToolbox 0x00007fff96a0f0a4 RunCurrentEventLoopInMode + 209
31 HIToolbox 0x00007fff96a0ee42 ReceiveNextEventCommon + 356
32 HIToolbox 0x00007fff96a0ecd3 BlockUntilNextEventMatchingListInMode + 62
33 AppKit 0x00007fff93292613 _DPSNextEvent + 685
34 AppKit 0x00007fff93291ed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
35 AppKit 0x00007fff93289283 -[NSApplication run] + 517
36 AppKit 0x00007fff9322dcb6 NSApplicationMain + 869这就是我得到的结论,
*** Assertion failure in -[MyCustomOutlineView _expandItemEntry:expandChildren:startLevel:], /SourceCache/AppKit/AppKit-1187.34/TableView.subproj/NSOutlineView.m:1309
2013-01-16 21:16:41.346 AppName[4149:303] (null) should not be expanded already!任何提示我如何调试它?
编辑场景
这是客户机-服务器应用程序,
Client will listen from a Socket in a **thread, and data will come in XML Format**
In the same thread it will Extract the XML Data and Form a NSMutableDictionary & NSMutableArray
something like this,
NSMutableArray *rootArray = will contain all first level of item,
each element of rootArray will be of type OutlineViewData class, this will contain any additional info whether they are single element or it can be another group item ,
if at all they are group item again there will be an array and so on..
**From listen thread i am calling OutlineView reload data over main thread.** 我所怀疑的
事情就是这样发生的
void SocketListenerThread(){
while ( hasData ){
if ( xmlOutLineData ){
pData = Make Outline Data ; // This is modifying the Data which will be
// display/used by the NSOutlineView
}
[ Call To Reload the NSOutlineView on the main thread ]
}
}我原以为NSOutlineView reloadData正在阻塞调用,但它似乎没有阻塞调用,这可能正在发生,我正在编辑/可能正在删除或添加一些条目到pData,该条目再次被NSOutline委托方法引用以显示Outlineview,
有没有办法让blockingBehavior of NSOutlineView reloadData提前感谢。
发布于 2013-01-16 22:45:42
reloadData只在NSOutlineView中设置一个标志以触发对数据源的调用。您的代码基本上是I繁忙循环,它永远不会返回到主runLoop来实际处理对GUI (或NSOutlineView实例本身)的任何状态更改。
您应该做的是在一个单独的线程上创建数据,并在主线程上调用一个刷新函数。
现在在与主线程不同的线程上调用非线程安全代码。
使用这样的方法:
[myController performSelectorOnMainThread:@selector(refreshOutlineView:) withObject:myDataArray waitUntilDone:YES];
refreshOutlineView应该将新分配的数据添加到数组或数据源中使用的任何底层对象中。
myDataArray包含您创建的数据记录。
之后,在该方法中调用reloadData。
https://stackoverflow.com/questions/14362505
复制相似问题