VirtualBox

Changeset 22689 in vbox


Ignore:
Timestamp:
Sep 2, 2009 1:45:51 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51802
Message:

VBoxPython/darwin: Use the core foundation runloop routines instead of the carbon event stuff, otherwise we cannot specify the returnAfterSourceHandled argument.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp

    r22687 r22689  
    500500#  include <iprt/thread.h>
    501501#  include <iprt/err.h>
    502 #  include <CarbonEvents.h>
     502#  include <CoreFoundation/CFRunLoop.h>
     503#  if MAC_OS_X_VERSION_MAX_ALLOWED == 1040 /* ASSUMES this means we're using the 10.4 SDK. */
     504#   include <CarbonEvents.h>
     505#  endif
    503506
    504507// Wrapper that checks if the queue has pending events.
     
    549552                        // Work any native per-thread event loops for good measure.
    550553#  ifdef RT_OS_DARWIN
    551                         RunCurrentEventLoop(0.0005 /*sec*/);
     554                        CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, false /*returnAfterSourceHandled*/);
    552555#  endif
    553556
     
    580583        // This deals with the common case where the caller is the main
    581584        // application thread and the queue is a native one.
    582         if (    isEventQueueNative(pQueue)
    583             &&  GetCurrentEventLoop() == GetMainEventLoop()
     585        if (    isEventQueueNative(pQueue)
     586#  if MAC_OS_X_VERSION_MAX_ALLOWED == 1040 /* ASSUMES this means we're using the 10.4 SDK. */
     587            &&  GetCurrentEventLoop() == GetMainEventLoop()
     588#  else
     589            &&  CFRunLoopGetMain() == CFRunLoopGetCurrent()
     590#  endif
    584591        ) {
    585                 OSStatus     orc       = -1;
    586                 EventTimeout rdTimeout = cMsTimeout < 0
    587                                        ? kEventDurationForever
    588                                        : (double)cMsTimeout / 1000;
     592                OSStatus       orc       = -1;
     593                CFTimeInterval rdTimeout = cMsTimeout < 0
     594                                         ? 1.0e10
     595                                         : (double)cMsTimeout / 1000;
    589596                Py_BEGIN_ALLOW_THREADS;
    590                 orc = RunCurrentEventLoop(rdTimeout);
     597                orc = CFRunLoopRunInMode(kCFRunLoopDefaultMode, rdTimeout, true /*returnAfterSourceHandled*/);
     598                if (orc == kCFRunLoopRunHandledSource)
     599                    orc = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, false /*returnAfterSourceHandled*/);
    591600                Py_END_ALLOW_THREADS;
    592                 if (!orc || orc == eventLoopQuitErr)
     601                if (!orc || orc == kCFRunLoopRunHandledSource)
    593602                        return 0;
    594603
    595                 if (orc != eventLoopTimedOutErr) {
    596                         NS_WARNING("Unexpected status code from RunCurrentEventLoop");
     604                if (orc != kCFRunLoopRunTimedOut) {
     605                        NS_WARNING("Unexpected status code from CFRunLoopRunInMode");
    597606                        RTThreadSleep(1); // throttle
    598607                }
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