[pyatspi2] Have getState return STATE_DEFUNCT rather than throw an exception



commit 3dfe4ab6f653af065836058e41d15a7f98f19ca3
Author: Mike Gorse <mgorse novell com>
Date:   Wed May 12 16:46:55 2010 -0400

    Have getState return STATE_DEFUNCT rather than throw an exception
    
    If a LookupError is received as a result of an object no longer existing,
    catch the exception and return STATE_DEFUNCT, in order to avoid throwing
    an exception where at-spi-corba would have held a ref count to the object.

 pyatspi/accessible.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/pyatspi/accessible.py b/pyatspi/accessible.py
index 0f968d8..b2b0e4e 100644
--- a/pyatspi/accessible.py
+++ b/pyatspi/accessible.py
@@ -418,7 +418,10 @@ class Accessible(BaseProxy):
                         return _marshal_state_set(self._cached_data.state)
                 else:
                         func = self.get_dbus_method("GetState", dbus_interface=ATSPI_ACCESSIBLE)
-                        return _marshal_state_set(func())
+                        try:
+                                return _marshal_state_set(func())
+                        except LookupError:
+                                return [STATE_DEFUNCT]
 
         def isEqual(self, other):
                 """



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