[cairo-commit] src/cairo.c src/cairo-font-face.c src/cairo-pattern.c src/cairo-scaled-font.c src/cairo-surface.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Jun 24 12:07:25 PDT 2008


 src/cairo-font-face.c   |    2 ++
 src/cairo-pattern.c     |    7 +++++--
 src/cairo-scaled-font.c |    4 ++--
 src/cairo-surface.c     |    5 +++--
 src/cairo.c             |    7 +++++--
 5 files changed, 17 insertions(+), 8 deletions(-)

New commits:
commit 74789a702bf5c62bc0d0361f139b2c94f67d5c6e
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 24 15:07:07 2008 -0400

    Cleanup _set_error functions a bit

diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index 97841b9..1d67398 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -63,6 +63,8 @@ _cairo_font_face_set_error (cairo_font_face_t *font_face,
     if (status == CAIRO_STATUS_SUCCESS)
 	return status;
 
+    /* Don't overwrite an existing error. This preserves the first
+     * error, which is the most significant. */
     _cairo_status_set_error (&font_face->status, status);
 
     return _cairo_error (status);
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index e603b63..22cd69c 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -63,10 +63,10 @@ const cairo_solid_pattern_t _cairo_pattern_none = {
 /**
  * _cairo_pattern_set_error:
  * @pattern: a pattern
- * @status: a status value indicating an error, (eg. not
- * %CAIRO_STATUS_SUCCESS)
+ * @status: a status value indicating an error
  *
  * Atomically sets pattern->status to @status and calls _cairo_error;
+ * Does nothing if status is %CAIRO_STATUS_SUCCESS.
  *
  * All assignments of an error status to pattern->status should happen
  * through _cairo_pattern_set_error(). Note that due to the nature of
@@ -81,6 +81,9 @@ static cairo_status_t
 _cairo_pattern_set_error (cairo_pattern_t *pattern,
 			  cairo_status_t status)
 {
+    if (status == CAIRO_STATUS_SUCCESS)
+	return status;
+
     /* Don't overwrite an existing error. This preserves the first
      * error, which is the most significant. */
     _cairo_status_set_error (&pattern->status, status);
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index acc72ea..31ff7cf 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -208,10 +208,10 @@ static const cairo_scaled_font_t _cairo_scaled_font_nil = {
 /**
  * _cairo_scaled_font_set_error:
  * @scaled_font: a scaled_font
- * @status: a status value indicating an error, (eg. not
- * %CAIRO_STATUS_SUCCESS)
+ * @status: a status value indicating an error
  *
  * Atomically sets scaled_font->status to @status and calls _cairo_error;
+ * Does nothing if status is %CAIRO_STATUS_SUCCESS.
  *
  * All assignments of an error status to scaled_font->status should happen
  * through _cairo_scaled_font_set_error(). Note that due to the nature of
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index f5a2f2f..c186dd9 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -96,10 +96,11 @@ _cairo_surface_copy_pattern_for_destination (const cairo_pattern_t *pattern,
 /**
  * _cairo_surface_set_error:
  * @surface: a surface
- * @status: a status value indicating an error, (eg. not
- * %CAIRO_STATUS_SUCCESS)
+ * @status: a status value indicating an error
  *
  * Atomically sets surface->status to @status and calls _cairo_error;
+ * Does nothing if status is %CAIRO_STATUS_SUCCESS or any of the internal
+ * status values.
  *
  * All assignments of an error status to surface->status should happen
  * through _cairo_surface_set_error(). Note that due to the nature of
diff --git a/src/cairo.c b/src/cairo.c
index 2fb5fc1..85cb4cd 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -93,10 +93,10 @@ _cairo_error (cairo_status_t status)
 /**
  * _cairo_set_error:
  * @cr: a cairo context
- * @status: a status value indicating an error, (eg. not
- * %CAIRO_STATUS_SUCCESS)
+ * @status: a status value indicating an error
  *
  * Atomically sets cr->status to @status and calls _cairo_error;
+ * Does nothing if status is %CAIRO_STATUS_SUCCESS.
  *
  * All assignments of an error status to cr->status should happen
  * through _cairo_set_error(). Note that due to the nature of the atomic
@@ -109,6 +109,9 @@ _cairo_error (cairo_status_t status)
 static void
 _cairo_set_error (cairo_t *cr, cairo_status_t status)
 {
+    if (status == CAIRO_STATUS_SUCCESS)
+	return status;
+
     /* Don't overwrite an existing error. This preserves the first
      * error, which is the most significant. */
     _cairo_status_set_error (&cr->status, status);


More information about the cairo-commit mailing list