[pyatspi2] Do not dispatch events while waiting for a reply from a method call



commit 192b592d83dde49fae8189ad5f11792bacf118cd
Author: Mike Gorse <mgorse novell com>
Date:   Wed May 5 12:40:12 2010 -0400

    Do not dispatch events while waiting for a reply from a method call

 pyatspi/busutils/bus.py   |   19 ++++++++++++++++++-
 pyatspi/busutils/proxy.py |    2 ++
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/pyatspi/busutils/bus.py b/pyatspi/busutils/bus.py
index cd919fc..ddbe42c 100644
--- a/pyatspi/busutils/bus.py
+++ b/pyatspi/busutils/bus.py
@@ -67,8 +67,22 @@ class _AccessibilityBus (_bus.BusConnection):
 	def __init__ (self, address, mainloop):
 		_bus.BusConnection.__init__(self, address, mainloop)
 		self._signal_queue = _queue.Queue ()
+                self.eventsFrozen = False
+                self.needEventDispatch = False
+
+        def freezeEvents(self):
+                self.eventsFrozen = True
+
+        def thawEvents(self):
+                self.eventsFrozen = False
+                if self.needEventDispatch:
+                	gobject.idle_add(self._event_dispatch)
+                        self.needEventDispatch = False
 
 	def _event_dispatch (self):
+                if self.eventsFrozen:
+                        self.needEventDispatch = True
+                        return
 		while not self._signal_queue.empty():
 			(func, args, kwargs) = self._signal_queue.get (False)
 			func (*args, **kwargs)
@@ -78,7 +92,10 @@ class _AccessibilityBus (_bus.BusConnection):
 		
 		def wrapper (*iargs, **ikwargs):
 			self._signal_queue.put ((func, iargs, ikwargs))
-                	gobject.idle_add(self._event_dispatch)
+                        if self.eventsFrozen:
+                	        self.needEventDispatch = True
+                        else:
+                	        gobject.idle_add(self._event_dispatch)
 
 		return _bus.BusConnection.add_signal_receiver (self, wrapper, *args, **kwargs)
 
diff --git a/pyatspi/busutils/proxy.py b/pyatspi/busutils/proxy.py
index 11143f3..6f84160 100644
--- a/pyatspi/busutils/proxy.py
+++ b/pyatspi/busutils/proxy.py
@@ -86,8 +86,10 @@ class AccessibilityProxy (_connection.ProxyObject):
                                 *iargs,
                                 **ikwargs)
 
+			self._bus.freezeEvents()
 			data.loop.run ()
 			AccessibilityProxy._main_loop_pool.put_nowait (data.loop)
+			self._bus.thawEvents()
 
 			#depth = gobject.main_depth()
 			#print ("\t" * depth) + "Post-recurse"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]