[Openmcl-devel] Core Animation demo
Gary Byers
gb at clozure.com
Tue Jul 7 21:39:59 PDT 2009
On Tue, 7 Jul 2009, Neil Baylis wrote:
> On Jul 7, 2009, at 8:47 PM, Raffael Cavallaro wrote:
>
>>
>> I have noticed one issue with your demo - If I attempt to run it a
>> second time without restarting ccl, the window appears, but without
>> the sprite.
>>
>
> I'm not seeing this. If I close the window before starting a new
> instance, the new one seems to work correctly. If I leave the first
> window open and start a new one, then the first one no longer responds
> to mouse events, but is still visible. Can you say exactly what steps
> you perform to generate the error?
>
>> There's this console error:
>> 7/7/09 11:38:48 PM dx86cl64[39512] layer _NSViewBackingLayer(0x1be5d0)
>> a={0, 0} p={0, 0} b=(0,0,900,600) superlayer=0x0 is already attached
>> to a context
>
> I think this message is referring to the layer that's associated with
> the entire view, not the one created by make-ca-layer. It has the same
> bounds as the view does. It's created (I believe) by the call:
>
> (#/setWantsLayer: v #$YES)
>
>>
>> IOW, somehow the call to make-ca-layer is trying to re-use the same
>> ca-
>> layer. I've found that changing this:
>>
>> (let* ((layer (#/init (objc:make-objc-instance "CALayer")))?
>>
>> to this:
>>
>> (let* ((layer (make-instance 'ns:ca-layer))?
>>
>> solves this issue, though I'm not sure why the first would produce
>> different results than the second, but, at least on my setup, it does?
>
> What happens if you use the first form (objc:make-objc-instance...)
> without calling #/init on it? (I only put the call to init there
> because I saw it in some sample code from Apple. I'm not sure what
> it's doing.)
OBJC:MAKE-OBJC-INSTANCE (or that there newfangled CL:MAKE-INSTANCE thing,
which is entirely equivalent) is basically
(#/init (#/alloc class)) ; allocate an instance of class, call #/init to initialize
; that instance.
Calling #/init on the value returned by either MAKE-INSTANCE or OBJC:MAKE-OBJC-INSTANCE
is therefore equivalent to
(#/init (#/init (#/alloc class)))
If an #/init method has side effects (like ... oh, attaching a layer to a context,
whatever that means), and can tell when those side effects have already taken
place, it'd certainly be justified in warning about that.
>
>
> Neil
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>
More information about the Openmcl-devel
mailing list