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: Sending events to nonexistant targets



On 20/05/2003 00:31, Frederick Cheung <email@hidden> wrote:

> On Monday, May 19, 2003, at 16:55 Europe/London, George Warner wrote:
>
>> On Sun, 18 May 2003 22:32:49 +0100, Frederick Cheung <email@hidden>
>> wrote:
>>> Does anyone know what is likely to happen if Carbon events are sent to
>>> targets that don't exist?
>>
>> I think they end up in the bit bucket. No harm, no foul (fowl?). ;-)
>
> although it would sometimes be useful if they ended up being sent to
> the application target (if for example you had attached a CFDictionary
> of processing results to the event and need to CFRelease it, even if it
> won't be used by the now inexistant target)

Good point. This is general question: how to release data in similar
cases? Example:

CreateEvent(NULL, kClass, kKind, 0, 0, &event);

SetEventParameter(
event, kEventParamPostTarget, typeEventTargetRef,
sizeof(target), &target);

str = CFStringCreate...
SetEventParameter(event, 'ABCD', 'ABCD', sizeof(str), &str);

h = NewHandle...
SetEventParameter(event, 'EFGH', 'EFGH', sizeof(h), &h);

// etc, etc.

PostEventToQueue(someQueue, event, kEventPriorityStandard);
ReleaseEvent(event);
// Can't release stuff at this point


I see two possible options:

1) release stuff in appropriate event handler. As the original
poster example shows this handler will not always be called.

2) Create some "smart" custom allocator and use it in CreateEvent.
This allocator will deallocate all the extra stuff when event is
released. Looks involved.

Anything prettier?

Mike
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



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.