[trace] Emit an 'index' for an undefined surface

Larry Ewing hit a bug in cairo-trace whereby it tried to create a similar
surface referencing an undefined object. This fix checks whether the
object has yet to be defined, and if not issues an index in order to copy
the appropriate operand from the stack.
This commit is contained in:
Chris Wilson 2009-08-13 15:49:11 +01:00
parent 3a483c2896
commit 50c7d637f3

View file

@ -3148,7 +3148,6 @@ cairo_surface_create_similar (cairo_surface_t *other,
int width, int height)
{
cairo_surface_t *ret;
long other_id;
long surface_id;
ret = DLCALL (cairo_surface_create_similar, other, content, width, height);
@ -3156,21 +3155,21 @@ cairo_surface_create_similar (cairo_surface_t *other,
_emit_line_info ();
if (other != NULL && _write_lock ()) {
other_id = _get_surface_id (other);
Object *obj;
obj = _get_object (SURFACE, other);
if (_pop_operands_to (SURFACE, other)) {
_consume_operand ();
_trace_printf ("%d %d //%s similar\n",
width,
height,
_content_to_string (content));
} else if (obj->defined) {
_trace_printf ("s%ld", obj->token);
} else {
_trace_printf ("s%ld %d %d //%s similar\n",
other_id,
width,
height,
_content_to_string (content));
_trace_printf ("%d index ", current_stack_depth - obj->operand - 1);
}
_trace_printf ("%d %d //%s similar\n",
width,
height,
_content_to_string (content));
_push_operand (SURFACE, ret);
_write_unlock ();
}