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: RemoveEventFromQueue()




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. 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.


-eric

_______________________________________________
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: 
 >RemoveEventFromQueue() (From: "Andreas Falkenhahn" <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.