Hi,

I'm having a problem with the retain count of CALayers. It seems that
when changing geometry related properties, such as bounds or position,
the retain count is decremented. Below is a simple example that
exhibits the problem. In the example, if changeName is called, the
retain count of the layer isn't touched, but if changePosition is
called, the retain count is decremented so far that the overridden
dealloc method is called.

I can hide the problem by turning on garbage collection, but that's
cheating. Does anyone have any ideas as to what might be causing this?

Cheers,
Pete

------------------------------------------------------------------------

@interface TestController : NSObject {
        IBOutlet NSView *view;
        TestLayer *_testLayer;
}

- (IBAction)changePosition:(id)sender;
- (IBAction)changeName:(id)sender;

@end

------------------------------------------------------------------------

@implementation TestController

- (void)awakeFromNib
{
        view.wantsLayer = YES;

        _testLayer = [[TestLayer alloc] init];
        _testLayer.name = @"layer1";
        [view.layer addSublayer:_testLayer];
}

- (void)dealloc
{
        [_testLayer release];
        [super dealloc];
}

- (IBAction)changePosition:(id)sender
{
        NSPoint newPosition = _testLayer.position;
        newPosition.x += 10;
        _testLayer.position = newPosition;
}

- (IBAction)changeName:(id)sender
{
        _testLayer.name = [_testLayer.name stringByAppendingString:@"1"];
}

@end

------------------------------------------------------------------------

@interface TestLayer : CATextLayer {
}

@end

------------------------------------------------------------------------

@implementation TestLayer

- (void)dealloc
{
        NSLog(@"TestLayer dealloc called");
        [super dealloc];
}

@end
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to