* registry.py: Fixed bug #436982 (Patch from Eitan), crash on exit
authorparente <parente@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Wed, 9 May 2007 18:42:05 +0000 (18:42 +0000)
committerparente <parente@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Wed, 9 May 2007 18:42:05 +0000 (18:42 +0000)
* utils.py: Fixed bug #437153, bad StateSet add/remove impl.

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@922 e2bd861d-eb25-0410-b326-f6ed22b6b98c

pyatspi/ChangeLog
pyatspi/registry.py
pyatspi/utils.py

index 33e6675..57ab829 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-09  Peter Parente  <parente@cs.unc.edu>
+
+       * registry.py: Fixed bug #436982 (Patch from Eitan), crash on exit
+       * utils.py: Fixed bug #437153, bad StateSet add/remove impl.
+
 2007-05-08  Peter Parente  <parente@cs.unc.edu>
 
        * constants.py: 
index bc36134..f1eafdc 100644 (file)
@@ -333,22 +333,35 @@ class Registry(object):
     '''
     self.async = async
     
-    # register a signal handler for gracefully killing the loop
-    signal.signal(signal.SIGINT, self.stop)
-    signal.signal(signal.SIGTERM, self.stop)
-  
     if gil:
       def releaseGIL():
-        time.sleep(1e-5)
+        try:
+          time.sleep(1e-5)
+        except KeyboardInterrupt, e:
+          # store the exception for later
+          releaseGIL.keyboard_exception = e
+          self.stop()
         return True
+      # make room for an exception if one occurs during the 
+      releaseGIL.keyboard_exception = None
       i = gobject.idle_add(releaseGIL)
       
     # enter the main loop
-    bonobo.main()
-    
-    if gil:
-      gobject.source_remove(i)
-    
+    try:
+      bonobo.main()
+    except KeyboardInterrupt, e:
+      # re-raise the keyboard interrupt
+      raise e
+    finally:
+      # clear all observers
+      for name, ob in self.observers.items():
+        ob.unregister(self.reg, name)
+      if gil:
+        gobject.source_remove(i)
+        if releaseGIL.keyboard_exception is not None:
+          # re-raise the keyboard interrupt we got during the GIL release
+          raise releaseGIL.keyboard_exception
+
   def stop(self, *args):
     '''Quits the main loop.'''
     try:
index a914375..7e825f3 100644 (file)
@@ -341,7 +341,7 @@ class StateSet(Accessibility__POA.StateSet):
     @param state: State(s) to add
     @type state: Accessibility.StateType
     '''
-    self.states.add(state)
+    map(self.states.add, state)
   
   def remove(self, *state):
     '''
@@ -350,7 +350,7 @@ class StateSet(Accessibility__POA.StateSet):
     @param state: State(s) to remove
     @type state: Accessibility.StateType
     '''
-    self.states.remove(state)
+    map(self.states.remove, state)
   
   def equals(self, state_set):
     '''