]> git.saurik.com Git - wxWidgets.git/commitdiff
wake up corrections : correcting ref count (mem-leak) , keeping weak ref to avoid...
authorStefan Csomor <csomor@advancedconcepts.ch>
Sat, 18 Dec 2004 10:55:19 +0000 (10:55 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sat, 18 Dec 2004 10:55:19 +0000 (10:55 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31054 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/utils.cpp

index d61ce0e905f0d5a574613a21399cfbe21e653348..baa5a937af9b20cbb340b6a5ea2ff8a9e0d26bb4 100644 (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 ) ;