VirtualBox

Changeset 23073 in vbox for trunk/src


Ignore:
Timestamp:
Sep 17, 2009 8:31:00 AM (15 years ago)
Author:
vboxsync
Message:

xpcom18a4/xpcom/threads/pleven.c: Backported the CFRunLoop changes from the mozilla1.8.0 branch. These changes are related to mozilla bugs 271050 and 282940. This should fix the VBoxHeadless issue on Snow Leopard.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c

    r1 r23073  
    6969#endif
    7070
    71 #if defined(XP_MAC) || defined(XP_MACOSX)
    72 #if !defined(MOZ_WIDGET_COCOA) && TARGET_CARBON
    73 #include <CarbonEvents.h>
    74 #define MAC_USE_CARBON_EVENT
    75 #else
    76 #include <Processes.h>
    77 #define MAC_USE_WAKEUPPROCESS
    78 #endif
    79 #endif
    80 
    81 #if defined(XP_MAC)
    82 #include "pprthred.h"
    83 #else
     71#if defined(XP_MACOSX)
     72#if defined(MOZ_WIDGET_COCOA)
     73#include <CoreFoundation/CoreFoundation.h>
     74#define MAC_USE_CFRUNLOOPSOURCE
     75#elif defined(TARGET_CARBON)
     76/* #include <CarbonEvents.h> */
     77/* #define MAC_USE_CARBON_EVENT */
     78#include <CoreFoundation/CoreFoundation.h>
     79#define MAC_USE_CFRUNLOOPSOURCE
     80#endif
     81#endif
     82
    8483#include "private/pprthred.h"
    85 #endif /* defined(XP_MAC) */
    8684
    8785#if defined(VMS)
     
    152150    PRPackedBool        processingEvents;
    153151    PRPackedBool        notified;
    154 #if defined(_WIN32) 
     152#if defined(_WIN32)
    155153    PRPackedBool        timerSet;
    156154#endif
     
    169167#elif defined(XP_BEOS)
    170168    port_id             eventport;
    171 #elif defined(XP_MAC) || defined(XP_MACOSX)
    172 #if defined(MAC_USE_CARBON_EVENT)
     169#elif defined(XP_MACOSX)
     170#if defined(MAC_USE_CFRUNLOOPSOURCE)
     171    CFRunLoopSourceRef  mRunLoopSource;
     172    CFRunLoopRef        mMainRunLoop;
     173#elif defined(MAC_USE_CARBON_EVENT)
    173174    EventHandlerUPP     eventHandlerUPP;
    174175    EventHandlerRef     eventHandlerRef;
    175 #elif defined(MAC_USE_WAKEUPPROCESS)
    176     ProcessSerialNumber psn;
    177176#endif
    178177#endif
     
    259258    self->removeMsg = PR_TRUE;
    260259#endif
    261 #if defined(MAC_USE_WAKEUPPROCESS)
    262     self->psn.lowLongOfPSN = kNoProcess;
    263 #endif
    264260
    265261    self->notified = PR_FALSE;
     
    286282}
    287283
    288 PR_EXTERN(PLEventQueue *) 
     284PR_EXTERN(PLEventQueue *)
    289285PL_CreateNativeEventQueue(const char *name, PRThread *handlerThread)
    290286{
     
    292288}
    293289
    294 PR_EXTERN(PLEventQueue *) 
     290PR_EXTERN(PLEventQueue *)
    295291PL_CreateMonitoredEventQueue(const char *name, PRThread *handlerThread)
    296292{
     
    307303_pl_destroyEvent(PLEvent* event, void* data, PLEventQueue* queue)
    308304{
    309 #ifdef XP_MAC
    310 #pragma unused (data, queue)
    311 #endif
    312305    PL_DequeueEvent(event, queue);
    313306    PL_DestroyEvent(event);
     
    735728PL_DequeueEvent(PLEvent* self, PLEventQueue* queue)
    736729{
    737 #ifdef XP_MAC
    738 #pragma unused (queue)
    739 #endif
    740730    if (self == NULL)
    741731        return;
     
    851841_pl_SetupNativeNotifier(PLEventQueue* self)
    852842{
    853 #if defined(XP_MAC)
    854 #pragma unused (self)
    855 #endif
    856 
    857843#if defined(VMS)
    858844    unsigned int status;
     
    907893    char portname[64];
    908894    char semname[64];
    909     PR_snprintf(portname, sizeof(portname), "event%lx", 
     895    PR_snprintf(portname, sizeof(portname), "event%lx",
    910896                (long unsigned) self->handlerThread);
    911     PR_snprintf(semname, sizeof(semname), "sync%lx", 
     897    PR_snprintf(semname, sizeof(semname), "sync%lx",
    912898                (long unsigned) self->handlerThread);
    913899
     
    932918_pl_CleanupNativeNotifier(PLEventQueue* self)
    933919{
    934 #if defined(XP_MAC)
    935 #pragma unused (self)
    936 #endif
    937 
    938920#if defined(VMS)
    939921    {
     
    953935    RemoveProp(self->eventReceiverWindow, _md_GetEventQueuePropName());
    954936
    955     /* DestroyWindow doesn't do anything when called from a non ui thread.  Since 
     937    /* DestroyWindow doesn't do anything when called from a non ui thread.  Since
    956938     * self->eventReceiverWindow was created on the ui thread, it must be destroyed
    957939     * on the ui thread.
     
    961943#elif defined(XP_OS2)
    962944    WinDestroyWindow(self->eventReceiverWindow);
     945#elif defined(MAC_USE_CFRUNLOOPSOURCE)
     946
     947    CFRunLoopRemoveSource(self->mMainRunLoop, self->mRunLoopSource, kCFRunLoopCommonModes);
     948    CFRelease(self->mRunLoopSource);
     949    CFRelease(self->mMainRunLoop);
     950
    963951#elif defined(MAC_USE_CARBON_EVENT)
    964952    EventComparatorUPP comparator = NewEventComparatorUPP(_md_CarbonEventComparator);
     
    12591247#endif /* XP_BEOS */
    12601248
    1261 #if defined(XP_MAC) || defined(XP_MACOSX)
     1249#if defined(XP_MACOSX)
    12621250static PRStatus
    12631251_pl_NativeNotify(PLEventQueue* self)
    12641252{
    1265 #if defined(MAC_USE_CARBON_EVENT)
     1253#if defined(MAC_USE_CFRUNLOOPSOURCE)
     1254        CFRunLoopSourceSignal(self->mRunLoopSource);
     1255        CFRunLoopWakeUp(self->mMainRunLoop);
     1256#elif defined(MAC_USE_CARBON_EVENT)
    12661257    OSErr err;
    12671258    EventRef newEvent;
     
    12771268    if (err != noErr)
    12781269        return PR_FAILURE;
    1279 #elif defined(MAC_USE_WAKEUPPROCESS)
    1280     WakeUpProcess(&self->psn);
    12811270#endif
    12821271    return PR_SUCCESS;
    12831272}
    1284 #endif /* defined(XP_MAC) || defined(XP_MACOSX) */
     1273#endif /* defined(XP_MACOSX) */
    12851274
    12861275static PRStatus
     
    13411330#else
    13421331
    1343 #if defined(XP_MAC)
    1344 #pragma unused (self)
    1345 #endif
    1346 
    13471332    /* nothing to do on the other platforms */
    13481333    return PR_SUCCESS;
     
    15771562#endif /* (defined(XP_UNIX) && !defined(XP_MACOSX)) || defined(XP_BEOS) */
    15781563
    1579 #if defined(MAC_USE_CARBON_EVENT)
     1564#if defined(MAC_USE_CFRUNLOOPSOURCE)
     1565static void _md_EventReceiverProc(void *info)
     1566{
     1567  PLEventQueue *queue = (PLEventQueue*)info;
     1568  PL_ProcessPendingEvents(queue);
     1569}
     1570
     1571#elif defined(MAC_USE_CARBON_EVENT)
    15801572/*
    15811573** _md_CreateEventQueue() -- ModelDependent initializer
     
    16191611#endif /* defined(MAC_USE_CARBON_EVENT) */
    16201612
    1621 #if defined(XP_MAC) || defined(XP_MACOSX)
     1613#if defined(XP_MACOSX)
    16221614static void _md_CreateEventQueue( PLEventQueue *eventQueue )
    16231615{
    1624 #if defined(MAC_USE_CARBON_EVENT)
     1616#if defined(MAC_USE_CFRUNLOOPSOURCE)
     1617    CFRunLoopSourceContext sourceContext = { 0 };
     1618    sourceContext.version = 0;
     1619    sourceContext.info = (void*)eventQueue;
     1620    sourceContext.perform = _md_EventReceiverProc;
     1621
     1622    /* make a run loop source */
     1623    eventQueue->mRunLoopSource = CFRunLoopSourceCreate(kCFAllocatorDefault, 0 /* order */, &sourceContext);
     1624    PR_ASSERT(eventQueue->mRunLoopSource);
     1625
     1626    eventQueue->mMainRunLoop = CFRunLoopGetCurrent();
     1627    CFRetain(eventQueue->mMainRunLoop);
     1628
     1629    /* and add it to the run loop */
     1630    CFRunLoopAddSource(eventQueue->mMainRunLoop, eventQueue->mRunLoopSource, kCFRunLoopCommonModes);
     1631
     1632#elif defined(MAC_USE_CARBON_EVENT)
    16251633    eventQueue->eventHandlerUPP = NewEventHandlerUPP(_md_EventReceiverProc);
    16261634    PR_ASSERT(eventQueue->eventHandlerUPP);
     
    16361644      PR_ASSERT(eventQueue->eventHandlerRef);
    16371645    }
    1638 #elif defined(MAC_USE_WAKEUPPROCESS)
    1639     OSErr err = GetCurrentProcess(&eventQueue->psn);
    1640     PR_ASSERT(err == noErr);
    16411646#endif
    16421647} /* end _md_CreateEventQueue() */
    1643 #endif /* defined(XP_MAC) || defined(XP_MACOSX) */
     1648#endif /* defined(XP_MACOSX) */
    16441649
    16451650/* extra functions for unix */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette