On 25.08.2007 at 17:45 Eric Schlegel wrote:
>On Aug 25, 2007, at 4:16 PM, Andreas Falkenhahn wrote:
>
>>
>> Hi,
>>
>> I want to keep certain events in the queue and remove them later.
>> Is it okay to do the following:
>>
>> if(ReceiveNextEvent(0, NULL, kEventDurationNoWait, FALSE, &theEvent)
>> == noErr)
>> {
>> if(GetEventClass(theEvent) != <event to skip>) {
>> SendEventToEventTarget(theEvent, theTarget);
>> RemoveEventFromQueue(GetMainEventQueue(), theEvent);
>> }
>> }
>>
>> I'm especially worried about the RemoveEventFromQueue(): Does it
>> release the
>> event? I'm asking because originally I had a ReleaseEvent() after
>> REFQ(), but
>> that crashed. So I suppose REFQ() releases the event too if its ref
>> count is 0.
>
>The refcounting is OK in this code; RemoveEventFromQueue does release
>the event.
Ok. That's why I suspected.
>However, I think there's a more fundamental problem here:
>if you get an event back from ReceiveNextEvent that you don't want to
>handle immediately, and therefore you leave the event in the queue,
>then that event will the first event from the queue from then on, and
>you'll keep getting it back from ReceiveNextEvent, so you'll never get
>any other event back until you handle that event. You would need to
>remove all events from the queue and, for those events you don't want
>to handle immediately, place those in your own data structure to keep
>track of them.
That's not necessary in my case because all events that I skip will be
removed and handled before the code above is called again. I take care
of that of course.
Andreas
_______________________________________________
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