From d6c69b17723c42d5114a464027fa307cabc66190 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 18 Dec 2004 10:55:19 +0000 Subject: [PATCH] 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 --- src/mac/carbon/utils.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index d61ce0e905..baa5a937af 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -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 ) ; -- 2.47.2