[Openmcl-devel] Autorelease question

Ron Garret ron at awun.net
Tue Jun 2 13:56:40 PDT 2009


Oh geez, never mind, I'm an idiot.  There's a call to ccl::with- 
autorelease-pool in my code.  Doh!

rg

On Jun 2, 2009, at 1:23 PM, Ron Garret wrote:

> This question arises from ticket #526 (http://trac.clozure.com/ccl/ticket/526
> ).  I'm moving the discussion to the list because I thought this might
> be of general interest.
>
> I do this:
>
> (defclass scribble-view (ns:ns-view)
>   ((path :initform (#/bezierPath ns:ns-bezier-path)))
>   (:metaclass ns:+ns-object))
>
> (defun make-scribble-window ()
>   (ccl::with-autorelease-pool
>    (let* ((rect (ns:make-ns-rect 0 0 300 300))
> 	  (w (make-instance 'ns:ns-window
> 			    :with-content-rect rect
> 			    :style-mask (logior #$NSTitledWindowMask
> 					       #$NSClosableWindowMask
> 					       #$NSMiniaturizableWindowMask
> 					       #$NSResizableWindowMask)
> 			    :backing #$NSBackingStoreBuffered
> 			    :defer t))
>           (v (make-instance 'scribble-view)))
>      (#/setTitle: w #@"Scribble")
>      (#/setContentView: w v)
>      (#/center w)
>      (#/orderFront: w nil)
>      (print (slot-value v 'path))
>      v)))
>
> (slot-value (make-scribble-window) 'path)
>
> and the result is a bogus ObjC object.  RME says this is because:
>
> "You are initializing the path slot in your scribble-view instance
> with an autoreleased NSBezierPath. The NSBezierPath instance will be
> released on the next trip through the event loop."
>
> But I don't understand why this should be the case.  The NSBezierPath
> object was not allocated on the event loop thread, so why should it be
> (auto)released there?  Doesn't every thread (and hence every listener)
> have its own autorelease pool?
>
> rg
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list