[Python-checkins] python/dist/src/Lib/plat-mac aetools.py,1.4,1.5
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Mon, 31 Mar 2003 05:29:38 -0800
Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv31716
Modified Files:
aetools.py
Log Message:
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.
Index: aetools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/aetools.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** aetools.py 28 Mar 2003 23:42:37 -0000 1.4
--- aetools.py 31 Mar 2003 13:29:32 -0000 1.5
***************
*** 24,27 ****
--- 24,28 ----
from types import *
from Carbon import AE
+ from Carbon import Evt
from Carbon import AppleEvents
import MacOS
***************
*** 145,148 ****
--- 146,159 ----
_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.
***************
*** 202,206 ****
def sendevent(self, event):
"""Send a pre-created appleevent, await the reply and unpack it"""
!
reply = event.AESend(self.send_flags, self.send_priority,
self.send_timeout)
--- 213,218 ----
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)