Commit graph

3487 commits

Author SHA1 Message Date
Chris Wilson
a6506c67f2 Don't return scaled fonts in the error state from the cache.
It is possible for a scaled_font to be flagged as in error, though only
through a "true error" e.g. a malloc failure. However, when returning a font
from the cache it should not be in error. So if we find a error font in the
cache we remove it and return a new font.
2007-04-11 15:57:03 -07:00
Carl Worth
0f0ed88ee2 paginated: Add missing error check for _cairo_surface_show_page
Fixing this uncovered a leak of a CAIRO_INT_STATUS_UNSUPPORTED value
up to cairo_show_page, (and similarly to cairo_copy_page). There was
really no good reason for _cairo_surface_show_page and
_cairo_surface_copy_page to be returning cairo_int_status_t. Fix
this by simply handling the UNSUPPORTED return at the surface layer
instead of the gstate layer.
2007-04-10 23:01:55 -07:00
Carl Worth
381f0bcafc paginated: Add missing error check for _cairo_surface_get_extents 2007-04-10 22:59:36 -07:00
Carl Worth
41911002d7 test-meta-surface.c: Fix memory leak on error recovery path. 2007-04-10 16:32:09 -07:00
Carl Worth
d954e4c148 Fix indentation of CLEANUP_IMAGE label. 2007-04-10 16:31:21 -07:00
Carl Worth
c011c37ba0 paginated: Fix missing errors checks for _cairo_meta_surface_replay 2007-04-10 16:30:43 -07:00
Carl Worth
e73a55ad3c cairo-truetype-subset: Fix missing error propagation 2007-04-10 14:26:39 -07:00
Carl Worth
97b8fd8117 cairo-truetype-subset: Check resturn value from _cairo_array_append and propagate 2007-04-10 14:26:31 -07:00
Carl Worth
84639e563d test-meta-surface: Add missing check for error from _cairo_surface_get_extents 2007-04-10 14:11:43 -07:00
Carl Worth
866b2296b4 test-meta-surface: Add missing checks for errors from _cairo_meta_surface_replay 2007-04-10 14:09:56 -07:00
Carl Worth
ec1fc93125 Add missing error check of return value of _cairo_path_fixed_close_path 2007-04-10 13:59:42 -07:00
Carl Worth
3d21037a8f Add assertion check to quiet warn_unused_result warning.
This is a somewhat useful internal consistency check.
2007-04-10 13:57:41 -07:00
Carl Worth
2f46867716 Rename _cairo_pdf_surface_emit_toUnicode_stream to eliminate StudlyCaps
Obviously, the new name is _cairo_pdf_surface_emit_to_unicode_stream which
is consistent with the to_unicode_stream identifiers already existing in
the implementation.
2007-04-10 13:53:58 -07:00
Carl Worth
cc6c115e3c PDF: Check return value of _cairo_output_stream_destroy and propagate 2007-04-10 13:51:46 -07:00
Carl Worth
8873928f09 PS: Add missing error checks for _cairo_output_stream_destroy 2007-04-10 13:40:04 -07:00
Carl Worth
ab5eccbbf6 Make _cairo_clip_reset void
Yet another unconditionally successful function---so it's easier to return nothing.
2007-04-10 13:28:48 -07:00
Chris Wilson
7a0ae5b705 Disable warnings for cairo_*_reference functions.
This class of functions modify their argument and return it as a
*convenience* for the caller. For example, within cairo a common idiom is:

    cairo_object_reference (new);
    cairo_object_unreference (this->obj);
    this->obj = new;

which updates the member to the new object irrespective of whether the
new object is the same as the one being replaced. Other issues arise
with subtypes, as the return type is the parent's and so require more
complicated handling to compile cleanly.

Disabling the warning is therefore preferred over adding code which
decreases readibility and reduces maintainability. We need to make the
compiler work for us, not against us...
2007-04-10 13:21:19 -07:00
Chris Wilson
b82e595449 pixman region operations can fail, propagate the error.
Copying the clip region could fail, add error returns and propagate up
the call stack.
2007-04-10 13:18:02 -07:00
Carl Worth
b0a256aaf3 Change _cairo_dtostr to have a void return type
As previously implemented, there's no essential information in the
return value from _cairo_dotostr, (the caller can simply use strlen
to recompute the same value, which is what the only caller is already
doing).

There would be real information in a return value which would return
the result from the call to snprintf for the case where the buffer is
not large enough for the number being printed.
2007-04-10 13:07:09 -07:00
Carl Worth
5303980f82 _cairo_output_stream_vprintf: Add assertion to detect internal inconsitency
This will catch any inconsistency between the length of a single
format specifier and the fixed size of the single_fmt buffer.
2007-04-10 13:03:37 -07:00
Carl Worth
97a69bc82e Fix mis-indented _cairo_dtostr 2007-04-10 12:13:27 -07:00
Carl Worth
5c95800cde Fix mis-indented _cairo_traps_init_box 2007-04-10 12:13:10 -07:00
Carl Worth
57188b4dcb Fix cairo_traps_t status handling
Add a _cairo_traps_status function and use it instead of adding
error checks to callers of _cairo_traps_add_trap and
_cairo_traps_add_trap_from_points, (both of which are now given
a void return type).
2007-04-10 12:06:09 -07:00
Carl Worth
67bc608603 Add missing error checking to _trace_mask_to_path
Note: It looks like it would be convenient to shove a status value
into cairo_path_fixed_t to reduce this sequence of error checks.
But I tried that first, and it actually makes things worse overall
due to many things like _cairo_path_fixed_move_to called by
cairo_move_to where the result must be immediately checked anyway.
So I've already rejected that approach.
2007-04-10 11:19:54 -07:00
Carl Worth
b1086caf3b Add a status field to cairo_polygon_t
Now, the functions to add new data to a polygon all become void,
and there's a new _cairo_polygon_status call to query the status
at the end of a sequence of operations.

With this change, we fix many callerswhich were previously not
checking the return values of _cairo_polygon functions by adding
only a single call to _cairo_polygon_status rathern than several
new checks.
2007-04-10 10:45:15 -07:00
Carl Worth
bff45ec9f9 Invert condition to more intuitive form.
The idiom for checking the return value of malloc is:

	if (pointer == NULL) { ... }

rather than:

	if (pointer != NULL) { ... }
2007-04-10 10:14:49 -07:00
Carl Worth
01955a6e82 Rename ARRAY_LEN to ARRAY_LENGTH
Yet another victim in my hunt against abbreviations within cairo's implementation.
2007-04-10 10:14:49 -07:00
Carl Worth
d317e8175d Prefer FALSE over 0 for initializing a cairo_bool_t value 2007-04-10 10:14:49 -07:00
Carl Worth
9a33dab969 Fix an incorrectly indented condition 2007-04-10 10:14:49 -07:00
Carl Worth
4bfc8c98cc ATSUI: Fix broken error checks for NULL surface
The cairo_image_surface_create function never returns NULL so
the previous error checks would never have triggered. The correct
approach is to check the result of cairo_surface_status().
2007-04-10 10:14:49 -07:00
Carl Worth
bd98295100 Add a couple of missing newline characters
A return statement that's not at the end of a function really needs
a line of whitespace after it.
2007-04-10 10:14:48 -07:00
Carl Worth
a7d8e52cc4 Cleanup multi-line if condition
The standard idiom of assigning to a local status variable looks much,
much nicer here.
2007-04-10 10:14:48 -07:00
Carl Worth
7c97696af9 Make _cairo_path_bounder_add_point void
Yet another function that cannot fail under any circumstances.
2007-04-09 17:16:30 -07:00
Carl Worth
93776772ed Make _cairo_matrix_compute_scale_factors void
Yet another function that cannot fail under any circumstances.
2007-04-09 17:15:33 -07:00
Carl Worth
d5b35d7d76 Make _cairo_pen_init_empty void
Yet another function that cannot fail under any circumstances.
2007-04-09 17:12:11 -07:00
Carl Worth
9077da99ab Make _cairo_gstate_user_to_device (and friends) void.
This is just multiplication after all, so there's nothing that can fail.
And we can get rid of a lot of useless error-checking code this way.
The corrected functions are:

	_cairo_gstate_user_to_device
	_cairo_gstate_user_to_device_distance
	_cairo_gstate_device_to_user
	_cairo_gstate_device_to_user_distance
2007-04-09 17:09:51 -07:00
Carl Worth
628ec8eb91 Make _cairo_gstate_identity_matrix void
Now that we have the warn_unused_result attribute enabled, (thanks
Chris!), it's actually harmful to have a function return an
uncoditional value of CAIRO_STATUS_SUCCESS. The harm is that
it would force lots of unnecessary error-checking paths that
just add clutter.

It is much better to simply give a function that cannot fail
a return type of void.
2007-04-09 17:03:29 -07:00
Chris Wilson
90803eca0f Implement clone_surface for test-fallback-surface.
A few tests were failing due to clip_init_deep_copy() not being able to
clone the target surface. Before propagating the failure, this was being
silently ignored.

Copy the simple implementation from cairo-image-surface.
2007-04-09 16:50:20 -07:00
Chris Wilson
4456ecbf26 Fix detection of FcFini().
It is customary to check for a FontConfig function in the FontConfig
library rather than the FreeType library.
2007-04-09 16:49:58 -07:00
Chris Wilson
cd2394c076 Free the bitmap->buffer on failure
Currently if the ownership of the bitmap->buffer is passed to
_get_bitmap_surface() then the status of the buffer is inconsistent
should the function detect an error (i.e. CAIRO_STATUS_NO_MEMORY).
Fix it up that should we encounter an error and we own the buffer then
we always free it on behalf of the caller.
2007-04-09 16:48:02 -07:00
Chris Wilson
ac33953a81 Correct handling of a malloc failure during pattern_create_in_error()
Confusion had been introduced as to who provided the fixup after
the malloc failed which resulted in a NULL deference whilst checking for
an erroneous pattern in _cairo_pattern_create_in_error.
2007-04-09 16:47:38 -07:00
Chris Wilson
ce1651f1ea Free the pixman_image if we fail to wrap it with a surface. 2007-04-09 16:39:05 -07:00
Chris Wilson
bd99507f15 Initialise cairo_spline_t to use its embedded buffer.
Currently the code defaults to setting its points to NULL and fixing it up
on the first add_point() to use the embedded buffer. Skip this extra step
by initialising points to the embedded buffer.
2007-04-09 16:38:29 -07:00
Chris Wilson
b2280c5ac2 Do not overwrite cr->status
The idiom for cairo.c is to do
    cr->status = _cairo_op ();
    if (cr->status) _cairo_set_error (cr, cr->status);

Unfortunately a trivial mistake for a _cairo_op () is to call a cairo_op ()
and forget to check cr->status but return CAIRO_STATUS_SUCCESS which will
mask the earlier error.

Obviously this is a bug in the lower level but the impact can be reduced
by chaning cairo.c to use a local status variable for its return:
    cairo_status_t status = _cairo_op ();
    if (status) _cairo_set_error (cr, cr->status);
2007-04-09 16:36:59 -07:00
Chris Wilson
14ac5dd78b Return the correct status from _cairo_pen_stroke_spline().
The return value is shared before the normal cleanup and error paths,
so do not simply return a hard-coded CAIRO_STATUS_SUCCESS.
2007-04-09 16:23:36 -07:00
Chris Wilson
b823e2f68f cairo-xlib-surface - propagate status returns.
These were found during a cairo_static pass on an alternative branch...

A critical one in particular was setting the have added glyph flag to
TRUE even if _cairo_xlib_surface_add_glyph() fails. This can cause an
application crash due to a RenderBadGlyph error later when the scaled
font is cleaned and we attempt to remove the glyph.
2007-04-09 16:22:48 -07:00
Chris Wilson
4a624b8e8b Remove the entry if we return an error code during _cair_hash_table_insert.
Previously if we detected an error during resize we would report a
failure to insert the entry into the hash table having already done so.
2007-04-09 16:19:41 -07:00
Chris Wilson
1cdb54f883 Reorder cleanup cairo_xlib_surface_show_glyphs()
_cairo_pattern_release_surface() asserts that it is passed a pattern
surface. This itself is bad as breaks the symmetry with
_cairo_pattern_acquire_surface under() error conditions, however reorder
the cleanup to avoid this assertion.
2007-04-09 16:18:29 -07:00
Chris Wilson
a1331fb043 Detect failure to allocate glyphs during _cairo_scaled_font_init()
If _cairo_cache_create fails, return CAIRO_STATUS_NO_MEMORY.
2007-04-09 16:13:41 -07:00
Chris Wilson
1237eedff3 Check for error whilst trying to advance along a text string.
The text perf-case tries to fill the region with a single text string,
but fails to detect when the current point does not advance due to an
error. This causes the perf-case to enter an infinite loop, so we break
out when the cairo_status() has been set.
2007-04-09 16:13:16 -07:00