Re: [Pyobjc-dev] Headache over hacking an XML editor
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2003-01-14 13:05:13
|
On Tuesday, Jan 14, 2003, at 05:00 US/Eastern, Just van Rossum wrote: >>> PythonItem.__new__ should return cls.alloc().init().release(). > > Hm, I just discovered .release() returns None. If I do the release() > separately it works just fine. I still don't understand why > cls.alloc().init() would result in a retainCount of 2, though. Every > time I see a retain() or release() call in Python code I can't help but > think there's something terribly wrong :-( It has to do with the way the retain/release mechanism works. In any case, you have one -retain for alloc() and one for the assignment in python. I agree that it would be very, very nice NOT to have to ever deal with retain/release/autorelease on the Python side of the PyObjC bridge. Unfortunately, it appears to be impossible [AFAICT] to automate the management of retain/release/autorelease with 100% reliability. Anything that makes assumptions regarding retain counts and adjusts the count downwards automatically will lead to situations where the app blows up. Ronald and I discussed this at length some time ago-- I believe it was before you had become active on the project. There is actually code to maintain the release counts automatically, it is currently commented out. Check the archives for more information.... b.bum |