wake up corrections : correcting ref count (mem-leak) , keeping weak ref to avoid double posting wakeup-events

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31054 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2004-12-18 10:55:19 +00:00
parent fbd3562061
commit d6c69b1772

View File

@@ -722,13 +722,26 @@ void wxMacWakeUp()
if ( isSame )
{
#if TARGET_CARBON
EventRef dummyEvent ;
// we keep the reference only as a weak ref, to avoid double posting
// wakeups, so no problem if it is stale
static EventRef s_wakeupEvent = 0 ;
if ( s_wakeupEvent )
{
// is our last wakeup still in the queue
if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent ) )
return ;
// has been used already
s_wakeupEvent = 0 ;
}
OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(),
kEventAttributeNone, &dummyEvent);
kEventAttributeNone, &s_wakeupEvent);
if (err == noErr)
{
err = PostEventToQueue(GetMainEventQueue(), dummyEvent,
err = PostEventToQueue(GetMainEventQueue(), s_wakeupEvent,
kEventPriorityHigh);
ReleaseEvent( s_wakeupEvent ) ;
}
#else
PostEvent( nullEvent , 0 ) ;