[cairo-commit] pycairo/cairo pycairo-context.c, 1.58, 1.59 cairogtkmodule.c, 1.27, 1.28

Steve Chaplin commit at pdx.freedesktop.org
Tue Jun 14 01:42:35 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv23718/cairo

Modified Files:
	pycairo-context.c cairogtkmodule.c 
Log Message:
SC

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- pycairo-context.c	14 Jun 2005 04:02:58 -0000	1.58
+++ pycairo-context.c	14 Jun 2005 08:42:33 -0000	1.59
@@ -38,7 +38,8 @@
 /* PycairoContext_FromContext
  * Create a new PycairoContext from a cairo_t
  * ctx  - a cairo_t to 'wrap' into a Python object.
- *        it is unreferenced if the PycairoContext creation fails
+ *        it is unreferenced if the PycairoContext creation fails, or if
+ *        the cairo_t has an error status
  * type - the type of the object to instantiate; it can be NULL,
  *        meaning a base cairo.Context type, or it can be a subclass of
  *        cairo.Context.
@@ -52,6 +53,12 @@
     PyObject *o;
 
     assert (ctx != NULL);
+
+    if (Pycairo_Check_Status (cairo_status (ctx))) {
+	cairo_destroy (ctx);
+	return NULL;
+    }
+
     if (type == NULL)
         type = &PycairoContext_Type;
     o = PycairoContext_Type.tp_alloc (type, 0);
@@ -96,16 +103,12 @@
     o = type->tp_alloc(type, 0);
     if (o) {
 	cairo_t *ctx = cairo_create (s->surface);
-	if (ctx) {
-	    if (Pycairo_Check_Status (cairo_status (ctx))) {
-		Py_DECREF(o);
-		return NULL;
-	    }
-	    ((PycairoContext *)o)->ctx = ctx;
-	}else {
+	if (Pycairo_Check_Status (cairo_status (ctx))) {
+	    cairo_destroy (ctx);
 	    Py_DECREF(o);
-	    return PyErr_NoMemory();
+	    return NULL;
 	}
+	((PycairoContext *)o)->ctx = ctx;
     }
     return o;
 }

Index: cairogtkmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairogtkmodule.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cairogtkmodule.c	1 Jun 2005 12:29:02 -0000	1.27
+++ cairogtkmodule.c	14 Jun 2005 08:42:33 -0000	1.28
@@ -140,10 +140,6 @@
 	return NULL;
 
     cr = gdk_cairo_create (GDK_DRAWABLE(py_drawable->obj));
-    if (!cr) {
-	PyErr_SetString(PyExc_RuntimeError, "could not create context");
-	return NULL;
-    }
     return PycairoContext_FromContext (cr, NULL, (PyObject *)py_drawable);
 }
 




More information about the cairo-commit mailing list