[Openmcl-devel] Three questions
    Kevin Reid 
    kpreid at mac.com
       
    Sat Feb  9 05:02:25 PST 2008
    
    
  
On Feb 8, 2008, at 19:54, Ron Garret wrote:
> Yes, but windows are a notable exception because one often wishes to
> retain pointers to them (so you can draw in them for example) but they
> can (and in the normal course of events often do) become deallocated
> asynchronously as a result of a user's actions, to wit, clicking on
> the "close" button.
Perhaps I have my facts wrong, as I haven't done any Cocoa  
programming in a long time (and have never used OpenMCL's bridge),  
but as far as I know, NSWindow is not *that much* of an exception to  
Cocoa reference counting rules.
That is, if you have a reference to the NSWindow, you should -retain  
it, and it will then not ever be deallocated out from under you. (Of  
course, you would then -release it in a finalizer on your Lisp  
container.)
(Disregard the above if OpenMCL automatically retains/releases  
foreign-pointers to ObjC objects.)
It sounds like setReleasedWhenClosed:YES might create an exception,  
but in that case -- turn that option off! Or make sure you don't  
"use" the first incrementing-of-reference-count that corresponds to - 
alloc (that is, that unit is "owned" by the internal release-when- 
closed mechanism), and retain it yourself separately.
-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>
    
    
More information about the Openmcl-devel
mailing list