My main thread creates a few other objects which have NSThreads and/or
timers. I have found that when I quit the app, and the threads are ended,
something in the OS is retaining my objects for a bit... They end up never
being dealloc'd which messes a few things up as some data is written to disk
at this point.

This fixes it:

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication
*)sender
{
    if (!prepareQuit)   // make sure we only do this part once
    {
        [myObjects release];    // the OS still retains them for a bit
        prepareQuit = YES;
    }
    
    if (objCount == 0)
        return (NSTerminateNow);
    
    else // wait around for everything to be cleaned up by the OS
    {
       [[NSApplication sharedApplication]
performSelector:@selector(terminate:) withObject:nil afterDelay:0.5];
        return (NSTerminateCancel);
    }
}

In my obj alloc I set objCount++ and in the dealloc I set objCount--

Is there a better way around this?

Without delaying the termination for the OS to clean up (guessing some
autorelease pool), some of my objects are never dealloc'd and the app simply
goes away with no error.

Thoughts?

Thanks,

Trygve


_______________________________________________

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