[atk: 1/2] Make sure returned values are initialized



commit 9118d44778e4d3a05810012cdcaa69eb4db2c389
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Wed Aug 14 16:18:37 2019 +0200

    Make sure returned values are initialized
    
    Some methods do not have a way to notify that they have failed.
    They should thus make sure that they set some value, rather than let them
    uninitialized and thus random.
    
    It allows to be sure that Orca will have a well-defined behavior rather
    than possibly very erratic behavior.

 atk/atkcomponent.c | 26 ++++++++++++++++++++++++++
 atk/atktext.c      | 10 ++++++++++
 atk/atkvalue.c     |  5 +++++
 3 files changed, 41 insertions(+)
---
diff --git a/atk/atkcomponent.c b/atk/atkcomponent.c
index e4a9c63..080d521 100644
--- a/atk/atkcomponent.c
+++ b/atk/atkcomponent.c
@@ -258,6 +258,9 @@ atk_component_ref_accessible_at_point (AtkComponent    *component,
  *
  * Gets the rectangle which gives the extent of the @component.
  *
+ * If the extent can not be obtained (e.g. a non-embedded plug or missing
+ * support), all of x, y, width, height are set to -1.
+ *
  **/
 void
 atk_component_get_extents    (AtkComponent    *component,
@@ -294,6 +297,13 @@ atk_component_get_extents    (AtkComponent    *component,
 
   if (iface->get_extents)
     (iface->get_extents) (component, real_x, real_y, real_width, real_height, coord_type);
+  else
+    {
+      *real_x = -1;
+      *real_y = -1;
+      *real_width = -1;
+      *real_height = -1;
+    }
 }
 
 /**
@@ -307,6 +317,9 @@ atk_component_get_extents    (AtkComponent    *component,
  * Gets the position of @component in the form of 
  * a point specifying @component's top-left corner.
  *
+ * If the position can not be obtained (e.g. a non-embedded plug or missing
+ * support), x and y are set to -1.
+ *
  * Deprecated: Since 2.12. Use atk_component_get_extents() instead.
  **/
 void
@@ -334,6 +347,11 @@ atk_component_get_position   (AtkComponent    *component,
 
   if (iface->get_position)
     (iface->get_position) (component, real_x, real_y, coord_type);
+  else
+    {
+      *real_x = -1;
+      *real_y = -1;
+    }
 }
 
 /**
@@ -344,6 +362,9 @@ atk_component_get_position   (AtkComponent    *component,
  *
  * Gets the size of the @component in terms of width and height.
  *
+ * If the size can not be obtained (e.g. a non-embedded plug or missing
+ * support), width and height are set to -1.
+ *
  * Deprecated: Since 2.12. Use atk_component_get_extents() instead.
  **/
 void
@@ -372,6 +393,11 @@ atk_component_get_size       (AtkComponent    *component,
 
   if (iface->get_size)
     (iface->get_size) (component, real_width, real_height);
+  else
+    {
+      *real_width = -1;
+      *real_height = -1;
+    }
 }
 
 /**
diff --git a/atk/atktext.c b/atk/atktext.c
index 23034c7..8f2e498 100644
--- a/atk/atktext.c
+++ b/atk/atktext.c
@@ -1062,6 +1062,9 @@ atk_text_set_caret_offset (AtkText *text,
  *
  * Get the bounding box for text within the specified range.
  *
+ * If the extents can not be obtained (e.g. or missing support), the rectangle
+ * fields are set to -1.
+ *
  * Since: 1.3
  **/
 void
@@ -1081,6 +1084,13 @@ atk_text_get_range_extents (AtkText          *text,
 
   if (iface->get_range_extents)
     (*(iface->get_range_extents)) (text, start_offset, end_offset, coord_type, rect);
+  else
+    {
+      rect->x = -1;
+      rect->y = -1;
+      rect->width = -1;
+      rect->height = -1;
+    }
 }
 
 /**
diff --git a/atk/atkvalue.c b/atk/atkvalue.c
index d52d754..5f56541 100644
--- a/atk/atkvalue.c
+++ b/atk/atkvalue.c
@@ -547,6 +547,11 @@ atk_value_get_value_and_text (AtkValue *obj,
     {
       (iface->get_value_and_text) (obj, value, text);
     }
+  else
+    {
+      *value = 0.0;
+      *text = NULL;
+    }
 }
 
 /**


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