1

私のアプリケーションには、あまりにも頻繁に更新され、クラッシュし、次のスタック トレースを取得する 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 が呼び出しをブロックしていると予想していましたが、呼び出しをブロックしていないようです。

NSOutlineView reloadDataのblockingBehaviorを持つ方法はありますか 事前に感謝..

4

1 に答える 1

-1

reloadDataNSOutlineView にフラグを設定して、データ ソースへの呼び出しをトリガーするだけです。runLoopあなたのコードは基本的にビジー ループであり、GUI (または NSOutlineView インスタンス自体) への状態変更を実際に処理するためにメインに戻ることはありません。

すべきことは、別のスレッドでデータを作成し、メイン スレッドで更新関数を呼び出すことです。

現在、メイン スレッドとは別のスレッドで非スレッド セーフ コードを呼び出しています。

次のようなものを使用します。
[myController performSelectorOnMainThread:@selector(refreshOutlineView:) withObject:myDataArray waitUntilDone:YES];

refreshOutlineView新しく作成されたデータを配列またはデータソースで使用する基礎となるオブジェクトに追加する必要があります。

myDataArray作成したデータ レコードが含まれます。

その後reloadData、そのメソッド内で呼び出します。

于 2013-01-16T22:45:42.983 に答える