[orca] Fix for bgo#598797 - Gnome-Terminal and VTE dump core when using Orca



commit 98161ad6cd09a732220db72bf79d94d4a7062b23
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sat Oct 17 19:07:18 2009 -0400

    Fix for bgo#598797 - Gnome-Terminal and VTE dump core when using Orca
    
    This adds a method, getTextEndOffset which scripts can override to
    provide an end offset other than -1 in the hopes it will be more
    palatable to the app being accessed.

 src/orca/default.py                     |   33 +++++++++++++++++++++++-------
 src/orca/scripts/apps/gnome-terminal.py |   12 +++++++++++
 2 files changed, 37 insertions(+), 8 deletions(-)
---
diff --git a/src/orca/default.py b/src/orca/default.py
index 428b19b..f53794a 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -4651,7 +4651,7 @@ class Script(script.Script):
         else:
             otherSelected = False
             text = obj.queryText()
-            displayedText = text.getText(0, -1)
+            displayedText = text.getText(0, self.getTextEndOffset(text))
             if (text.caretOffset == 0) or len(displayedText) == 0:
                 current = obj
                 morePossibleSelections = True
@@ -4665,7 +4665,8 @@ class Script(script.Script):
                             if prevObjText.getNSelections() > 0:
                                 otherSelected = True
                             else:
-                                displayedText = prevObjText.getText(0, -1)
+                                displayedText = prevObjText.getText(0,
+                                    self.getTextEndOffset(prevObjText))
                                 if len(displayedText) == 0:
                                     current = prevObj
                                     morePossibleSelections = True
@@ -4683,7 +4684,8 @@ class Script(script.Script):
                             if nextObjText.getNSelections() > 0:
                                 otherSelected = True
                             else:
-                                displayedText = nextObjText.getText(0, -1)
+                                displayedText = nextObjText.getText(0,
+                                    self.getTextEndOffset(nextObjText))
                                 if len(displayedText) == 0:
                                     current = nextObj
                                     morePossibleSelections = True
@@ -6310,7 +6312,7 @@ class Script(script.Script):
         except NotImplementedError:
             pass
         else:
-            displayedText = text.getText(0, -1)
+            displayedText = text.getText(0, self.getTextEndOffset(text))
 
             # [[[WDW - HACK to account for things such as Gecko that want
             # to use the EMBEDDED_OBJECT_CHARACTER on a label to hold the
@@ -6481,7 +6483,7 @@ class Script(script.Script):
                     except NotImplementedError:
                         continue
                     else:
-                        if text.getText(0, -1):
+                        if text.getText(0, self.getTextEndOffset(text)):
                             realActiveDescendant = child
 
         # [[[TODO: WDW - this is an odd hacky thing I've somewhat drawn
@@ -7096,6 +7098,19 @@ class Script(script.Script):
         else:
             return top.name
 
+    def getTextEndOffset(self, textInterface):
+        """Returns the offset which should be used as the end offset.
+        By default, this is -1. However, this value triggers an assertion
+        in certain apps. See bug 598797.
+
+        Argument:
+        - textInterface: the accessible text interface for which the end
+          offset is desired.
+
+        """
+
+        return -1
+
     def getTextLineAtCaret(self, obj, offset=None):
         """Gets the line of text where the caret is.
 
@@ -8235,7 +8250,8 @@ class Script(script.Script):
                         current = prevObj
                         morePossibleSelections = True
                     else:
-                        displayedText = prevObjText.getText(0, -1)
+                        displayedText = prevObjText.getText(0,
+                            self.getTextEndOffset(prevObjText))
                         if len(displayedText) == 0:
                             current = prevObj
                             morePossibleSelections = True
@@ -8257,7 +8273,8 @@ class Script(script.Script):
                         current = nextObj
                         morePossibleSelections = True
                     else:
-                        displayedText = nextObjText.getText(0, -1)
+                        displayedText = nextObjText.getText(0,
+                            self.getTextEndOffset(nextObjText))
                         if len(displayedText) == 0:
                             current = nextObj
                             morePossibleSelections = True
@@ -8401,7 +8418,7 @@ class Script(script.Script):
         except NotImplementedError:
             return '', 0, 0
 
-        text_contents = ti.getText(0, -1)
+        text_contents = ti.getText(0, self.getTextEndOffset(ti))
         line_offsets = []
         start_offset = 0
         while True:
diff --git a/src/orca/scripts/apps/gnome-terminal.py b/src/orca/scripts/apps/gnome-terminal.py
index 2e09762..4dd0d2f 100644
--- a/src/orca/scripts/apps/gnome-terminal.py
+++ b/src/orca/scripts/apps/gnome-terminal.py
@@ -313,3 +313,15 @@ class Script(default.Script):
 
         return string, caretOffset, lineOffset
         
+    def getTextEndOffset(self, textInterface):
+        """Returns the offset which should be used as the end offset.
+        By default, this is -1. However, this value triggers an assertion
+        in certain apps. See bug 598797.
+
+        Argument:
+        - textInterface: the accessible text interface for which the end
+          offset is desired.
+
+        """
+
+        return textInterface.characterCount



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