[pygobject/pygobject-3-30] foreign-cairo: add error handling for the pygobject API initialization



commit accc4dcd1140fbc1150e8dd9293396a95a093128
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Mon Sep 17 19:35:00 2018 +0200

    foreign-cairo: add error handling for the pygobject API initialization
    
    I can fail in case it's called at the wrong point in pygobject's own
    module init phase, which is what I tried.

 gi/pygi-foreign-cairo.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index c398cb72..718f9a0f 100644
--- a/gi/pygi-foreign-cairo.c
+++ b/gi/pygi-foreign-cairo.c
@@ -539,6 +539,8 @@ cairo_matrix_release (GIBaseInfo *base_info,
 static PyMethodDef _gi_cairo_functions[] = { {0,} };
 PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
 {
+    PyObject *gobject_mod;
+
 #if PY_VERSION_HEX < 0x03000000
     Pycairo_IMPORT;
 #else
@@ -548,7 +550,10 @@ PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
     if (Pycairo_CAPI == NULL)
         return PYGLIB_MODULE_ERROR_RETURN;
 
-    pygobject_init (3, 13, 2);
+    gobject_mod = pygobject_init (3, 13, 2);
+    if (gobject_mod == NULL)
+        return PYGLIB_MODULE_ERROR_RETURN;
+    Py_DECREF (gobject_mod);
 
     pygi_register_foreign_struct ("cairo",
                                   "Matrix",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]