Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Closing windows with event handlers attached



On 3/2/05 6:20 PM, Peter S Lau didst favor us with:

> On Mar 1, 2005, at 10:12 PM, Bryan Pietrzak wrote:
> 
>> On Mar 1, 2005, at 8:13 PM, Andrew Gillanders wrote:
>> 
>>> I have a normal document window (standard event handler installed)
>>> which has an event handler attached to it. When I close the window,
>>> are the event handlers automatically discarded, or do I have to
>>> explicitly remove them before closing the window?
>> 
>> Yes, when a target goes away, any handler installed on it is removed.
> 
> I am under the impression that if you install the handler using
> NewEventHandlerUPP(), you will need to call DisposeEventHandlerUPP()
> manually.

This is correct. If this were not the case, the technique below wouldn't
work. However the handler is removed from the target, which is a different
concept. If you wanted to remove it manually you would call
RemoveEventHandler().

Larry

> But there's also the common practice to have a static variable to
> allocate NewEventHandlerUPP() once, use it everywhere, and don't call
> DisposeEventHandlerUPP() and let your process ends with it.
> 
> So depends on what you are doing...
> 
> pete
> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Carbon-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/carbon-dev/email@hidden
> 
> This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: Closing windows with event handlers attached (From: Peter S Lau <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.