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



commit ba14b9fcac523e6cc76bebea0656b6625a1c36f9
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Mon Aug 19 15:44:28 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.
    
    This is a follow-up for 9118d44778e4 ("Make sure returned values are
    initialized")

 atk/atkimage.c |  6 ++++++
 atk/atktext.c  | 11 +++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/atk/atkimage.c b/atk/atkimage.c
index 5080150..3a7bdc7 100644
--- a/atk/atkimage.c
+++ b/atk/atkimage.c
@@ -97,6 +97,9 @@ atk_image_get_image_description (AtkImage *image)
  * Get the width and height in pixels for the specified image.
  * The values of @width and @height are returned as -1 if the
  * values cannot be obtained (for instance, if the object is not onscreen).
+ *
+ * If the size can not be obtained (e.g. missing support), x and y are set
+ * to -1.
  **/
 void
 atk_image_get_image_size (AtkImage *image, 
@@ -171,6 +174,9 @@ atk_image_set_image_description (AtkImage        *image,
  * 
  * Gets the position of the image in the form of a point specifying the
  * images top-left corner.
+ *
+ * If the position can not be obtained (e.g. missing support), x and y are set
+ * to -1.
  **/
 void     
 atk_image_get_image_position (AtkImage *image,
diff --git a/atk/atktext.c b/atk/atktext.c
index 8f2e498..fec90b0 100644
--- a/atk/atktext.c
+++ b/atk/atktext.c
@@ -665,6 +665,9 @@ atk_text_get_caret_offset (AtkText *text)
  * @height: (out) (optional): Pointer for the height of the bounding box
  * @coords: specify whether coordinates are relative to the screen or widget window 
  *
+ * If the extent can not be obtained (e.g. missing support), all of x, y, width,
+ * height are set to -1.
+ *
  * Get the bounding box containing the glyph representing the character at 
  *     a particular text offset. 
  **/
@@ -700,10 +703,10 @@ atk_text_get_character_extents (AtkText *text,
   else
     real_height = &local_height;
 
-  *real_x = 0;
-  *real_y = 0;
-  *real_width = 0;
-  *real_height = 0;
+  *real_x = -1;
+  *real_y = -1;
+  *real_width = -1;
+  *real_height = -1;
 
   if (offset < 0)
     return;


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