NSTreeController with Garbage Collection without CoreData causes problems
NSTreeController with Garbage Collection without CoreData causes problems
- Subject: NSTreeController with Garbage Collection without CoreData causes problems
- From: Eckart Schlottmann <email@hidden>
- Date: Mon, 25 Feb 2008 23:31:49 +0100
Hi,
I need some help on NSTreeController usage.
I use an NSTreecontroller with Garbage Collection and OBJ C 2.0.
I have a Structure of Nodes (class FileSystemEntry) which provide
children as a NSMutableArray with a getter and setter for the complete
arrays:
- (NSMutableArray *)internalChildren {
return internalChildren;
}
- (void)setInternalChildren:(NSMutableArray *)newValue
{
internalChildren = newValue;
}
When I click a button in my GUI the complete content of the
internalChildren is recomputed. I allocate a new NSMutableArray, feed
in some objects (partly the same but also) or even no objects anymore.
That means that a node which was a node having children suddenly gets
a node without children and that a subnode of this node may also not
longer be visible. A Node can therefore change from a node which is
not a leaf node to a node which is a leaf node. By this also complete
subtrees can be not longer visible for the user.
(Background: The application recursively compares directories. If the
user chooses not to see any subdirectory with only equal files anymore
complete subtrees may disappear from the view).
-(BOOL) isLeaf {
return isLeaf;
}
-(void)setLeaf:(BOOL)v {
isLeaf=v;
}
Both setters I perform synchronized.
When I scroll now my tree I get the following exception ->
EXC_BAD_ACCESS or similar effects where the binding tries to access an
object which is already removed by the garbage collector:
#0 0x91cb66e8 in objc_msgSend ()
#1 0x92679c24 in -[_NSTreeNodeObservingTracker
_registerOrUnregister:observerNotificationsForModelObject:] ()
#2 0x9267a0a4 in -[_NSTreeNodeObservingTracker
_stopObservingModelObject:] ()
#3 0x9255560b in -[NSOutlineViewBinder
tableView:updateVisibleRowInformation:] ()
#4 0x922e77e6 in -[_NSBindingAdaptor
tableView:updateVisibleRowInformation:] ()
#5 0x92081f2f in -[NSTableView drawRect:] ()
#6 0x92112bbe in -[NSView _drawRect:clip:] ()
#7 0x921104d8 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] ()
#8 0x92110f05 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView
:] ()
#9 0x9210c52d in -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] ()
#10 0x9204cf09 in -[NSView displayIfNeeded] ()
#11 0x92198e1b in -[NSClipView _immediateScrollToPoint:] ()
#12 0x92197df4 in -[NSClipView scrollToPoint:] ()
#13 0x92204d67 in -[NSScrollView scrollClipView:toPoint:] ()
#14 0x921323d5 in -[NSClipView _scrollTo:animate:] ()
#15 0x9222f09e in -[NSScrollView _doScroller:hitPart:multiplier:] ()
#16 0x9222ec86 in -[NSScrollView _doScroller:] ()
#17 0x9211be56 in -[NSApplication sendAction:to:from:] ()
#18 0x9211bd94 in -[NSControl sendAction:to:] ()
#19 0x9222ec27 in -[NSScroller sendAction:to:] ()
#20 0x9222e8f5 in -[NSScroller trackKnob:] ()
#21 0x9222d9d4 in -[NSScroller mouseDown:] ()
#22 0x92118ac3 in -[NSWindow sendEvent:] ()
#23 0x920e5714 in -[NSApplication sendEvent:] ()
#24 0x920430f9 in -[NSApplication run] ()
#25 0x9201030a in NSApplicationMain ()
#26 0x00006723 in main (argc=1, argv=0xbffff700) at /Users/eschlot/
Desktop/projects/BindingTest2/main.m:13
(gdb)
Before I get this I see empty lines in my NSOutlineView. It seems that
the binding is not removed from my objects in my internal model when I
replace the NSMutableArray. The strange thing is that it works fine if
I don't replace that many things or my tree is not that deeply nested
(I could not track down this).
No, I don't use any CoreData. I fill the structure completely on my
own. If I do not try to replace the content of my tree the bindings
work fine. It seems to be a problem of removing the NSTreeController's
Observers from my objects when I replace the arrays - but I don't know
what exactly causes this.
Btw: I also tried to manipulate the array object by object in KVO
complaint way instead of simply replacing the complete NSMutableArray,
but also this did have the same effect.
Does anybody have an idea?
What extra info do You require?
Greetings
Eckart Schlottmann
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden