[cairo-commit] 2 commits - src/cairo.h src/cairo-surface-observer.c

Andrea Canciani ranma42 at kemper.freedesktop.org
Sat Feb 11 06:24:35 PST 2012


 src/cairo-surface-observer.c |   30 +++++++++++++++++-------------
 src/cairo.h                  |    4 ++--
 2 files changed, 19 insertions(+), 15 deletions(-)

New commits:
commit 469994ac199179b40bafee951c92595706256cea
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Mon Jan 30 15:34:10 2012 +0100

    observer: Silence gcc warning
    
    GCC complains that:
    
    cairo-surface-observer.c:289:26: warning: ignoring return value of
    'cairo_device_acquire', declared with attribute warn_unused_result
    [-Wunused-result]
    
    Explain why it's safe to ignore it in a comment.

diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c
index 3ac0892..6d57bf6 100644
--- a/src/cairo-surface-observer.c
+++ b/src/cairo-surface-observer.c
@@ -286,7 +286,11 @@ static void
 _cairo_device_observer_lock (void *_device)
 {
     cairo_device_observer_t *device = (cairo_device_observer_t *) _device;
-    cairo_device_acquire (device->target);
+    cairo_status_t ignored;
+
+    /* cairo_device_acquire() can fail for nil and finished
+     * devices. We don't care about observing them. */
+    ignored = cairo_device_acquire (device->target);
 }
 
 static void
commit f2567e95a164d3874909baf09b94b45288604e53
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Mon Jan 30 15:12:57 2012 +0100

    observer: Return status when printing the observed data
    
    Making cairo_surface_observer_print() and
    cairo_device_observer_print() return the status of the observer or of
    the stream makes it possible to correctly track what kind of error
    happens if the print is not successful.
    
    This makes the functions more consistent with existing API with a
    similar signature like cairo_surface_write_to_png_stream().

diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c
index e5d3371..3ac0892 100644
--- a/src/cairo-surface-observer.c
+++ b/src/cairo-surface-observer.c
@@ -1957,7 +1957,7 @@ _cairo_observation_print (cairo_output_stream_t *stream,
     cairo_device_destroy (script);
 }
 
-void
+cairo_status_t
 cairo_surface_observer_print (cairo_surface_t *abstract_surface,
 			      cairo_write_func_t write_func,
 			      void *closure)
@@ -1965,17 +1965,17 @@ cairo_surface_observer_print (cairo_surface_t *abstract_surface,
     cairo_output_stream_t *stream;
     cairo_surface_observer_t *surface;
 
-    if (unlikely (CAIRO_REFERENCE_COUNT_IS_INVALID (&abstract_surface->ref_count)))
-	return;
+    if (unlikely (abstract_surface->status))
+	return abstract_surface->status;
 
-    if (! _cairo_surface_is_observer (abstract_surface))
-	return;
+    if (unlikely (! _cairo_surface_is_observer (abstract_surface)))
+	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 
     surface = (cairo_surface_observer_t *) abstract_surface;
 
     stream = _cairo_output_stream_create (write_func, NULL, closure);
     _cairo_observation_print (stream, &surface->log);
-    _cairo_output_stream_destroy (stream);
+    return _cairo_output_stream_destroy (stream);
 }
 
 double
@@ -1993,7 +1993,7 @@ cairo_surface_observer_elapsed (cairo_surface_t *abstract_surface)
     return _cairo_time_to_ns (_cairo_observation_total_elapsed (&surface->log));
 }
 
-void
+cairo_status_t
 cairo_device_observer_print (cairo_device_t *abstract_device,
 			     cairo_write_func_t write_func,
 			     void *closure)
@@ -2001,17 +2001,17 @@ cairo_device_observer_print (cairo_device_t *abstract_device,
     cairo_output_stream_t *stream;
     cairo_device_observer_t *device;
 
-    if (unlikely (CAIRO_REFERENCE_COUNT_IS_INVALID (&abstract_device->ref_count)))
-	return;
+    if (unlikely (abstract_device->status))
+	return abstract_device->status;
 
-    if (! _cairo_device_is_observer (abstract_device))
-	return;
+    if (unlikely (! _cairo_device_is_observer (abstract_device)))
+	return _cairo_error (CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
 
     device = (cairo_device_observer_t *) abstract_device;
 
     stream = _cairo_output_stream_create (write_func, NULL, closure);
     _cairo_observation_print (stream, &device->log);
-    _cairo_output_stream_destroy (stream);
+    return _cairo_output_stream_destroy (stream);
 }
 
 double
diff --git a/src/cairo.h b/src/cairo.h
index a64a8a0..0a004f3 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2192,14 +2192,14 @@ cairo_surface_observer_add_finish_callback (cairo_surface_t *abstract_surface,
 					    cairo_surface_observer_callback_t func,
 					    void *data);
 
-cairo_public void
+cairo_public cairo_status_t
 cairo_surface_observer_print (cairo_surface_t *surface,
 			      cairo_write_func_t write_func,
 			      void *closure);
 cairo_public double
 cairo_surface_observer_elapsed (cairo_surface_t *surface);
 
-cairo_public void
+cairo_public cairo_status_t
 cairo_device_observer_print (cairo_device_t *device,
 			     cairo_write_func_t write_func,
 			     void *closure);


More information about the cairo-commit mailing list