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
This commit is contained in:
@@ -722,13 +722,26 @@ void wxMacWakeUp()
|
|||||||
if ( isSame )
|
if ( isSame )
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#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(),
|
OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(),
|
||||||
kEventAttributeNone, &dummyEvent);
|
kEventAttributeNone, &s_wakeupEvent);
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
{
|
{
|
||||||
err = PostEventToQueue(GetMainEventQueue(), dummyEvent,
|
err = PostEventToQueue(GetMainEventQueue(), s_wakeupEvent,
|
||||||
kEventPriorityHigh);
|
kEventPriorityHigh);
|
||||||
|
ReleaseEvent( s_wakeupEvent ) ;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
PostEvent( nullEvent , 0 ) ;
|
PostEvent( nullEvent , 0 ) ;
|
||||||
|
Reference in New Issue
Block a user