diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-03-31 13:29:32 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-03-31 13:29:32 (GMT) |
commit | 397e9142096d5ccd2b4a63bc04d3b05b3c86cc48 (patch) | |
tree | 9f799cafb9e1a0584019ecf8cb4a0e4b6c065e74 /Lib | |
parent | 1fff697f8a6f6ff009fc7b23b212a941cfedaf6c (diff) | |
download | cpython-397e9142096d5ccd2b4a63bc04d3b05b3c86cc48.zip cpython-397e9142096d5ccd2b4a63bc04d3b05b3c86cc48.tar.gz cpython-397e9142096d5ccd2b4a63bc04d3b05b3c86cc48.tar.bz2 |
In TalkTo.send(), check that we have access to the window manager,
and initialize the event loop (if not done previously) to work around
a bug (IMHO) in MacOSX 10.2.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/plat-mac/aetools.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/plat-mac/aetools.py b/Lib/plat-mac/aetools.py index 0639541..9111d50 100644 --- a/Lib/plat-mac/aetools.py +++ b/Lib/plat-mac/aetools.py @@ -23,6 +23,7 @@ files: the pack stuff from aepack, the objects from aetypes. from types import * from Carbon import AE +from Carbon import Evt from Carbon import AppleEvents import MacOS import sys @@ -144,6 +145,16 @@ class TalkTo: _signature = None # Can be overridden by subclasses _moduleName = None # Can be overridden by subclasses + __eventloop_initialized = 0 + def __ensure_WMAvailable(klass): + if klass.__eventloop_initialized: return 1 + if not MacOS.WMAvailable(): return 0 + # Workaround for a but in MacOSX 10.2: we must have an event + # loop before we can call AESend. + Evt.WaitNextEvent(0,0) + return 1 + __ensure_WMAvailable = classmethod(__ensure_WMAvailable) + def __init__(self, signature=None, start=0, timeout=0): """Create a communication channel with a particular application. @@ -201,7 +212,8 @@ class TalkTo: def sendevent(self, event): """Send a pre-created appleevent, await the reply and unpack it""" - + if not self.__ensure_WMAvailable(): + raise RuntimeError, "No window manager access, cannot send AppleEvent" reply = event.AESend(self.send_flags, self.send_priority, self.send_timeout) parameters, attributes = unpackevent(reply, self._moduleName) |