mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-06 01:30:19 +01:00
Remove CAIRO_STATUS_NO_TARGET_SURFAC and add CAIRO_STATUS_INVALID_STATUS.
Don't check for gstate->target == NULL anymore as the API now guarantees it never occurs. Check that path->status is a valid status value and cause an INVALID_STATUS error otherwise. Test the new CAIRO_STATUS_INVALID_STATUS error case in cairo_append_path.
This commit is contained in:
parent
eb12e49308
commit
f766e06d25
5 changed files with 60 additions and 27 deletions
18
ChangeLog
18
ChangeLog
|
|
@ -1,3 +1,21 @@
|
|||
2005-07-06 Carl Worth <cworth@cworth.org>
|
||||
|
||||
* src/cairo.h:
|
||||
* src/cairo.c: (cairo_status_to_string): Remove
|
||||
CAIRO_STATUS_NO_TARGET_SURFAC and add CAIRO_STATUS_INVALID_STATUS.
|
||||
|
||||
* src/cairo-gstate.c:
|
||||
(_cairo_gstate_clip_and_composite_trapezoids),
|
||||
(_cairo_gstate_copy_page), (_cairo_gstate_show_page): Don't check
|
||||
for gstate->target == NULL anymore as the API now guarantees it
|
||||
never occurs.
|
||||
|
||||
* src/cairo.c: (cairo_append_path): Check that path->status is a
|
||||
valid status value and cause an INVALID_STATUS error otherwise.
|
||||
|
||||
* test/path-data.c: (main): Test the new
|
||||
CAIRO_STATUS_INVALID_STATUS error case in cairo_append_path.
|
||||
|
||||
2005-07-06 Carl Worth <cworth@cworth.org>
|
||||
|
||||
* configure.in: Require libpixman >= 0.1.5, (since 0.1.4 crashes
|
||||
|
|
|
|||
|
|
@ -1376,9 +1376,6 @@ _cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,
|
|||
if (traps->num_traps == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (gstate->target == NULL)
|
||||
return CAIRO_STATUS_NO_TARGET_SURFACE;
|
||||
|
||||
status = _cairo_traps_extract_region (traps, &trap_region);
|
||||
if (status)
|
||||
return status;
|
||||
|
|
@ -1515,18 +1512,12 @@ BAIL:
|
|||
cairo_status_t
|
||||
_cairo_gstate_copy_page (cairo_gstate_t *gstate)
|
||||
{
|
||||
if (gstate->target == NULL)
|
||||
return CAIRO_STATUS_NO_TARGET_SURFACE;
|
||||
|
||||
return _cairo_surface_copy_page (gstate->target);
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_gstate_show_page (cairo_gstate_t *gstate)
|
||||
{
|
||||
if (gstate->target == NULL)
|
||||
return CAIRO_STATUS_NO_TARGET_SURFACE;
|
||||
|
||||
return _cairo_surface_show_page (gstate->target);
|
||||
}
|
||||
|
||||
|
|
|
|||
18
src/cairo.c
18
src/cairo.c
|
|
@ -62,7 +62,7 @@ static const cairo_t cairo_nil = {
|
|||
* a bit of a pain, but it should be easy to always catch as long as
|
||||
* one adds a new test case to test a trigger of the new status value.
|
||||
*/
|
||||
#define CAIRO_STATUS_LAST_STATUS CAIRO_STATUS_SURFACE_TYPE_MISMATCH
|
||||
#define CAIRO_STATUS_LAST_STATUS CAIRO_STATUS_PATTERN_TYPE_MISMATCH
|
||||
|
||||
/**
|
||||
* _cairo_error:
|
||||
|
|
@ -2268,13 +2268,21 @@ cairo_append_path (cairo_t *cr,
|
|||
return;
|
||||
}
|
||||
|
||||
if (path == NULL || path->data == NULL) {
|
||||
if (path == NULL) {
|
||||
_cairo_error (cr, CAIRO_STATUS_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
|
||||
if (path->status) {
|
||||
_cairo_error (cr, path->status);
|
||||
if (path->status <= CAIRO_STATUS_LAST_STATUS)
|
||||
_cairo_error (cr, path->status);
|
||||
else
|
||||
_cairo_error (cr, CAIRO_STATUS_INVALID_STATUS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (path->data == NULL) {
|
||||
_cairo_error (cr, CAIRO_STATUS_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2305,8 +2313,8 @@ cairo_status_to_string (cairo_status_t status)
|
|||
return "no current point defined";
|
||||
case CAIRO_STATUS_INVALID_MATRIX:
|
||||
return "invalid matrix (not invertible)";
|
||||
case CAIRO_STATUS_NO_TARGET_SURFACE:
|
||||
return "no target surface has been set";
|
||||
case CAIRO_STATUS_INVALID_STATUS:
|
||||
return " invalid value for an input cairo_status_t";
|
||||
case CAIRO_STATUS_NULL_POINTER:
|
||||
return "NULL pointer";
|
||||
case CAIRO_STATUS_INVALID_STRING:
|
||||
|
|
|
|||
27
src/cairo.h
27
src/cairo.h
|
|
@ -127,19 +127,20 @@ typedef struct _cairo_user_data_key {
|
|||
/**
|
||||
* cairo_status_t
|
||||
* @CAIRO_STATUS_SUCCESS: no error has occurred
|
||||
* @CAIRO_STATUS_NO_MEMORY:
|
||||
* @CAIRO_STATUS_INVALID_RESTORE:
|
||||
* @CAIRO_STATUS_NO_MEMORY: out of memory
|
||||
* @CAIRO_STATUS_INVALID_RESTORE: cairo_restore without matching cairo_save
|
||||
* @CAIRO_STATUS_INVALID_POP_GROUP:
|
||||
* @CAIRO_STATUS_NO_CURRENT_POINT:
|
||||
* @CAIRO_STATUS_INVALID_MATRIX:
|
||||
* @CAIRO_STATUS_NO_TARGET_SURFACE:
|
||||
* @CAIRO_STATUS_NULL_POINTER:
|
||||
* @CAIRO_STATUS_INVALID_STRING:
|
||||
* @CAIRO_STATUS_INVALID_PATH_DATA:
|
||||
* @CAIRO_STATUS_READ_ERROR:
|
||||
* @CAIRO_STATUS_WRITE_ERROR:
|
||||
* @CAIRO_STATUS_SURFACE_FINISHED:
|
||||
* @CAIRO_STATUS_SURFACE_TYPE_MISMATCH:
|
||||
* @CAIRO_STATUS_NO_CURRENT_POINT: no current point defined
|
||||
* @CAIRO_STATUS_INVALID_MATRIX: invalid matrix (not invertible)
|
||||
* @CAIRO_STATUS_INVALID_STATUS: invalid value for an input cairo_status_t
|
||||
* @CAIRO_STATUS_NULL_POINTER: NULL pointer
|
||||
* @CAIRO_STATUS_INVALID_STRING: input string not valid UTF-8
|
||||
* @CAIRO_STATUS_INVALID_PATH_DATA: input path data not valid
|
||||
* @CAIRO_STATUS_READ_ERROR: error while reading from input stream
|
||||
* @CAIRO_STATUS_WRITE_ERROR: error while writing to output stream
|
||||
* @CAIRO_STATUS_SURFACE_FINISHED: target surface has been finished
|
||||
* @CAIRO_STATUS_SURFACE_TYPE_MISMATCH: the surface type is not appropriate for the operation
|
||||
* @CAIRO_STATUS_PATTERN_TYPE_MISMATCH: the pattern type is not appropriate for the operation
|
||||
*
|
||||
* #cairo_status_t is used to indicate errors that can occur when
|
||||
* using Cairo. In some cases it is returned directly by functions.
|
||||
|
|
@ -153,7 +154,7 @@ typedef enum cairo_status {
|
|||
CAIRO_STATUS_INVALID_POP_GROUP,
|
||||
CAIRO_STATUS_NO_CURRENT_POINT,
|
||||
CAIRO_STATUS_INVALID_MATRIX,
|
||||
CAIRO_STATUS_NO_TARGET_SURFACE,
|
||||
CAIRO_STATUS_INVALID_STATUS,
|
||||
CAIRO_STATUS_NULL_POINTER,
|
||||
CAIRO_STATUS_INVALID_STRING,
|
||||
CAIRO_STATUS_INVALID_PATH_DATA,
|
||||
|
|
|
|||
|
|
@ -151,9 +151,24 @@ main (void)
|
|||
return 1;
|
||||
cairo_destroy (cr);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
path.status = -1;
|
||||
cairo_append_path (cr, &path);
|
||||
if (cairo_status (cr) != CAIRO_STATUS_INVALID_STATUS)
|
||||
return 1;
|
||||
cairo_destroy (cr);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
path.status = CAIRO_STATUS_NO_MEMORY;
|
||||
cairo_append_path (cr, &path);
|
||||
if (cairo_status (cr) != CAIRO_STATUS_NO_MEMORY)
|
||||
return 1;
|
||||
cairo_destroy (cr);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
path.data = NULL;
|
||||
path.num_data = 0;
|
||||
path.status = CAIRO_STATUS_SUCCESS;
|
||||
cairo_append_path (cr, &path);
|
||||
if (cairo_status (cr) != CAIRO_STATUS_NULL_POINTER)
|
||||
return 1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue