[cairo-commit] pycairo/cairo cairogtkmodule.c, 1.30,
1.31 pycairo-font.c, 1.25, 1.26 pycairo-surface.c, 1.49, 1.50
Steve Chaplin
commit at pdx.freedesktop.org
Mon Aug 1 03:25:49 PDT 2005
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv10796/cairo
Modified Files:
cairogtkmodule.c pycairo-font.c pycairo-surface.c
Log Message:
'SC'
Index: cairogtkmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairogtkmodule.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- cairogtkmodule.c 22 Jul 2005 10:15:59 -0000 1.30
+++ cairogtkmodule.c 1 Aug 2005 10:25:47 -0000 1.31
@@ -82,8 +82,6 @@
gdk_pixbuf_get_width(gdk_pixbuf),
gdk_pixbuf_get_height(gdk_pixbuf),
gdk_pixbuf_get_rowstride(gdk_pixbuf));
- if (!surface)
- return PyErr_NoMemory();
return PycairoSurface_FromSurface (surface, &PycairoImageSurface_Type,
(PyObject *)py_pixbuf);
}
Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- pycairo-font.c 29 Jul 2005 22:03:39 -0000 1.25
+++ pycairo-font.c 1 Aug 2005 10:25:47 -0000 1.26
@@ -50,6 +50,12 @@
PyObject *o;
assert (font_face != NULL);
+
+ if (Pycairo_Check_Status (cairo_font_face_status (font_face))) {
+ cairo_font_face_destroy (font_face);
+ return NULL;
+ }
+
o = PycairoFontFace_Type.tp_alloc (&PycairoFontFace_Type, 0);
if (o)
((PycairoFontFace *)o)->font_face = font_face;
@@ -154,6 +160,12 @@
PyObject *o;
assert (scaled_font != NULL);
+
+ if (Pycairo_Check_Status (cairo_scaled_font_status (scaled_font))) {
+ cairo_scaled_font_destroy (scaled_font);
+ return NULL;
+ }
+
o = PycairoScaledFont_Type.tp_alloc (&PycairoScaledFont_Type, 0);
if (o)
((PycairoScaledFont *)o)->scaled_font = scaled_font;
@@ -197,9 +209,10 @@
cairo_scaled_font_t *scaled_font = cairo_scaled_font_create
(ff->font_face, &mx1->matrix, &mx2->matrix, fo->font_options);
- if (!scaled_font) {
+ if (Pycairo_Check_Status (cairo_scaled_font_status (scaled_font))) {
+ cairo_scaled_font_destroy (scaled_font);
Py_DECREF(o);
- return PyErr_NoMemory();
+ return NULL;
}
((PycairoScaledFont *)o)->scaled_font = scaled_font;
}
Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- pycairo-surface.c 29 Jul 2005 22:03:46 -0000 1.49
+++ pycairo-surface.c 1 Aug 2005 10:25:47 -0000 1.50
@@ -47,7 +47,8 @@
/* PycairoSurface_FromSurface
* Create a new PycairoSurface from a cairo_surface_t
* surface - a cairo_surface_t to 'wrap' into a Python object.
- * it is unreferenced if the PycairoSurface creation fails
+ * it is unreferenced if the PycairoSurface creation fails, or if
+ the cairo_surface_t has an error status
* type - the type of the object to instantiate; it can be NULL,
* meaning a base cairo.Surface type, or it can be a subclass of
* cairo.Surface.
@@ -63,6 +64,12 @@
PyObject *o;
assert (surface != NULL);
+
+ if (Pycairo_Check_Status (cairo_surface_status (surface))) {
+ cairo_surface_destroy (surface);
+ return NULL;
+ }
+
if (type == NULL)
type = &PycairoSurface_Type;
o = PycairoSurface_Type.tp_alloc (type, 0);
@@ -115,8 +122,6 @@
surface = cairo_surface_create_similar (o->surface, content,
width, height);
- if (!surface)
- return PyErr_NoMemory();
/* bug #2765 - "How do we identify surface types?"
* should pass surface type as arg2
*/
@@ -247,12 +252,12 @@
o = type->tp_alloc(type, 0);
if (o) {
surface = cairo_image_surface_create (format, width, height);
- if (surface) {
- ((PycairoImageSurface *)o)->surface = surface;
- } else {
+ if (Pycairo_Check_Status (cairo_surface_status (surface))) {
+ cairo_surface_destroy (surface);
Py_DECREF(o);
- return PyErr_NoMemory();
+ return NULL;
}
+ ((PycairoImageSurface *)o)->surface = surface;
}
return o;
}
@@ -313,9 +318,6 @@
array->dimensions[1],
array->dimensions[0],
array->strides[0]);
-
- if (!surface)
- return PyErr_NoMemory();
return PycairoSurface_FromSurface(surface, &PycairoImageSurface_Type,
(PyObject *)array);
}
@@ -366,9 +368,6 @@
surface = cairo_image_surface_create_for_data
((unsigned char *)data, format, width, height, stride);
- if (!surface)
- return PyErr_NoMemory();
-
return PycairoSurface_FromSurface(surface, &PycairoImageSurface_Type,
NULL);
/* FIXME: get surface to hold a reference to buffer */
@@ -412,11 +411,6 @@
if (PyObject_TypeCheck (o, &PyBaseString_Type))
fclose (fp);
- if (!surface) {
- PyErr_SetString(PyExc_ValueError, "invalid PNG file or memory "
- "could not be allocated for operation");
- return NULL;
- }
return PycairoSurface_FromSurface (surface, &PycairoImageSurface_Type,
NULL);
}
@@ -520,12 +514,12 @@
if (o) {
surface = cairo_pdf_surface_create (filename, width_in_points,
height_in_points);
- if (surface) {
- ((PycairoPDFSurface *)o)->surface = surface;
- } else {
+ if (Pycairo_Check_Status (cairo_surface_status (surface))) {
+ cairo_surface_destroy (surface);
Py_DECREF(o);
- return PyErr_NoMemory();
+ return NULL;
}
+ ((PycairoPDFSurface *)o)->surface = surface;
}
return o;
}
@@ -613,12 +607,12 @@
if (o) {
surface = cairo_ps_surface_create (filename, width_in_points,
height_in_points);
- if (surface) {
- ((PycairoPSSurface *)o)->surface = surface;
- } else {
+ if (Pycairo_Check_Status (cairo_surface_status (surface))) {
+ cairo_surface_destroy (surface);
Py_DECREF(o);
- return PyErr_NoMemory();
+ return NULL;
}
+ ((PycairoPSSurface *)o)->surface = surface;
}
return o;
}
@@ -703,12 +697,12 @@
o = type->tp_alloc(type, 0);
if (o) {
surface = cairo_win32_surface_create ((HDC)hdc);
- if (surface) {
- ((PycairoPSSurface *)o)->surface = surface;
- } else {
+ if (Pycairo_Check_Status (cairo_surface_status (surface))) {
+ cairo_surface_destroy (surface);
Py_DECREF(o);
- return PyErr_NoMemory();
+ return NULL;
}
+ ((PycairoPSSurface *)o)->surface = surface;
}
return o;
}
More information about the cairo-commit
mailing list