correcting dangling refs / reuse

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2004-12-19 16:40:18 +00:00
parent 35b92f0530
commit 8dfef0c246

View File

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