From 8dfef0c246fb5c741334ecc085aea56324bc0bf8 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sun, 19 Dec 2004 16:40:18 +0000 Subject: [PATCH] correcting dangling refs / reuse git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/utils.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index baa5a937af..593223fd7f 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -722,27 +722,21 @@ void wxMacWakeUp() if ( isSame ) { #if TARGET_CARBON - // 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 ) + static wxMacCarbonEvent s_wakeupEvent ; + OSStatus err = noErr ; + if ( !s_wakeupEvent.IsValid() ) { - // is our last wakeup still in the queue - if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent ) ) - return ; - // has been used already - s_wakeupEvent = 0 ; + err = s_wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(), + kEventAttributeNone ) ; } - - 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, kEventPriorityHigh); - ReleaseEvent( s_wakeupEvent ) ; - } + } #else PostEvent( nullEvent , 0 ) ; #endif -- 2.45.2