El 09/06/2008, a las 3:06, Nathan Kinsinger escribió:


On Jun 8, 2008, at 4:02 PM, Joan Lluch (casa) wrote:

Ok, I did it. This is now a confirmed bug. To reproduce it:

Modify the OutlineEdit example as follows:

1- In IB add set the "highlight" property of the outlineView to "Source List"

2- In IB set the delegate of the outlineView to the "owner" (the document in this case)

3- Add the following method to myDocument.m

- (BOOL)outlineView:(NSOutlineView *)sender isGroupItem:(id)item
{
 NSLog( @"item: %@", item) ;
 return NO ;
}

Then compile and run the app. In the running OutlineEdit.app do the following:

1- add a new child by pressing "new Child" or using the main menu.

2- select a different node than the one created in step 1

3- choose "undo" in the main menu.

Voila! : the app crashes in isGroupItem with EXC_BAD_ACCESS.

Actually you don't need to do any of that. Using the OutlineEdit example as is:

1) press New Child twice
2) undo twice

gdb prints an error: objc[21639]: FREED(id): message hash sent to freed object=0x16702600

If I run it with NSZombieEnabled I get:
OutlineEdit[21574:10b] *** -[NSTreeControllerTreeNode hash]: message sent to deallocated instance 0x1657fc80

The stack trace
#0      0x907bf907 in ___forwarding___
#1      0x907bfa12 in __forwarding_prep_0___
#2      0x90743226 in CFHash
#3      0x907467fb in __CFSetFindBuckets1b
#4      0x90746c89 in CFSetRemoveValue
#5      0x94c9ea48 in removeChildRowEntries
#6      0x94c9c6c0 in -[NSOutlineView reloadItem:reloadChildren:]
#7      0x94fb55b7 in -[NSOutlineViewBinder _childrenChangedForNode:]
#8 0x94fb57ed in -[NSOutlineViewBinder observeValueForKeyPath:ofObject:change:context:]
#9      0x90bb50ce in NSKVONotify
#10 0x90b31702 in -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] #11 0x9515412f in -[NSTreeControllerTreeNode updateChildNodesForKeyPath:] #12 0x95152073 in -[NSTreeControllerTreeNode observeValueForKeyPath:ofObject:change:context:]
#13     0x90bb50ce in NSKVONotify
#14 0x90bd38d2 in -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:withSetMutation:usingObjects:] #15 0x92c08706 in -[NSManagedObject didChangeValueForKey:withSetMutation:usingObjects:] #16 0x92c4a752 in -[NSManagedObject(_NSInternalMethods) _updateToManyRelationship:from:to:with:] #17 0x92c3df3c in -[NSManagedObject(_NSInternalMethods) _updateFromSnapshot:] #18 0x92c4b0b9 in - [NSManagedObjectContext(_NSInternalChangeProcessing) _undoUpdates:]
#19     0x90c19102 in -[_NSUndoLightInvocation invoke]
#20     0x90c06be4 in -[_NSUndoStack popAndInvoke]
#21     0x90c069e7 in -[NSUndoManager undoNestedGroup]
#22     0x94b7cc23 in -[NSApplication sendAction:to:from:]
#23     0x94c2b660 in -[NSMenu performActionForItemAtIndex:]
#24 0x94c2b365 in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:]
#25     0x94c2afeb in -[NSMenu performKeyEquivalent:]
#26     0x94c29890 in -[NSApplication _handleKeyEquivalent:]
#27     0x94b46853 in -[NSApplication sendEvent:]
#28     0x94aa3e27 in -[NSApplication run]
#29     0x94a71030 in NSApplicationMain
#30     0x00002c02 in main at main.m:53

It won't crash if you select each child as you undo them or if you collapse the root Note item before the undo. In the first case I wonder if the selection in the NSTreeController or the NSOutlineView are keeping the node around long enough. I'm guessing that reloadItem:reloadChildren: has NO for reloadChildren in the latter case and doesn't use the child node at all.

So somehow the NSOutlineView has weak references to the NSTreeControllerTreeNode children and they are being released from under it???

Your test case catches the error sooner because by the time outlineView:isGroupItem: is called item is already released so it crashes in the NSLog. But it would crash if you used item for anything. And it has nothing to do with the view being in Source List mode or group items.

Sorry but my gdb-foo is not strong enough to go farther.

The archive for this list has posts from quite a number of people having trouble with NSTreeController and CoreData.

--Nathan

Thanks for posting this. I found an even simpler example app that will crash. You can download it at:

http://developer.apple.com/samplecode/AbstractTree/index.html

Create several nodes and then perform undo. It crashes !


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to