Re: CFRunLoopObserver causes crash on NSView drag.
Re: CFRunLoopObserver causes crash on NSView drag.
- Subject: Re: CFRunLoopObserver causes crash on NSView drag.
- From: Ken Thomases <email@hidden>
- Date: Sat, 22 Oct 2011 09:48:40 -0500
On Oct 22, 2011, at 8:53 AM, Mr. Gecko wrote:
> static NSAutoreleasePool *pool = nil;
>
> void runloop(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info) {
> if (activity & kCFRunLoopEntry) {
> if (pool!=nil) [pool drain];
> pool = [NSAutoreleasePool new];
> } else if (activity & kCFRunLoopExit) {
> [pool drain];
> pool = nil;
> }
> }
I very much doubt this is kosher. An autorelease pool exists in a stack. If the outer autorelease pool is popped, then yours is deallocated whether or not you've released or drained it. After that happens, you have a dangling pointer. It really makes no sense to have an autorelease pool with a lifetime greater than the scope of its usage.
Have you tried running a timer to see if that provokes draining of the autorelease pool managed by the framework? Have you tried posting a custom event?
Even if those fail, the best approach is to just use local autorelease pools in whatever methods you introduce which are creating temporary objects that would otherwise live longer than you'd like.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden