Re: [Pyobjc-dev] Still struggling with NSOutlineView
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-01-18 21:51:18
|
On Saturday, Jan 18, 2003, at 20:55 Europe/Amsterdam, Just van Rossum wrote: > Ronald Oussoren wrote: > >> I found the problem: You didn't really hold onto the references to the >> childeren. >> >> The attached version of PythonBrowser.py works a lot better. > > Ah, nice, thanks. That may have been a problem, but it did work for me > before, as long as PythonItem was subclassed from NSObject. The main > issue is that it doesn't work when it _isn't_ subclassed from NSObject: > it crashes as soon as you click (hm, I seem to recall it didn't crash > before your patch, maybe other PyObjC changes play a role...). It crashes when PythonItem is not subclasses from NSObject because NSOutlineView stashes away the result of outlineView_child_ofItem_ *without increasing its reference count*. Later on it uses this pointer. If PythonItem is not subclassed from NSObject the values seem by outlineView:child:ofItem: (e.g. the Objective-C implementation) is an autoreleased proxy object (instance of OC_PythonObject). The PythonItem instance does not contain a reference to this proxy and therefore this will be autoreleased on the next loop through the eventloop. If the outlineview tries to use the proxy object later on your application goes boom. > >> However, >> when I try to expand the tree at a __doc__ item the program crashes >> (AttributeError: No attribute childeren) > > Erm, where do you see a __doc__ item that's expandable? __doc__ is > usually a stirng or None, neither of which should be expandable... If I start the PythonBrowser.app the window is filled with a the globals of the module, one of these is the __doc__ (which of type NoneType and has value None). On my system it is shown as an expandable item, but it is not in fact expandable. The problem is larger than that: class AutoBaseClass is not expandable, while NiceError is. This doesn't seem to be a problem with the script: I've added some print-statements and those print the expected results. This might indicate a problem with the bridge. Ronald |