]> git.saurik.com Git - wxWidgets.git/commitdiff
correcting dangling refs / reuse
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 19 Dec 2004 16:40:18 +0000 (16:40 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 19 Dec 2004 16:40:18 +0000 (16:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/utils.cpp

index baa5a937af9b20cbb340b6a5ea2ff8a9e0d26bb4..593223fd7f0f5c95467409c11b7a3c25838e2e75 100644 (file)
@@ -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