[pybank] Couple of memory fixes
- From: Johan Dahlin <johan src gnome org>
- To: svn-commits-list gnome org
- Subject: [pybank] Couple of memory fixes
- Date: Tue, 2 Jun 2009 10:46:33 -0400 (EDT)
commit 0116ba83196fe465cf8884c1608f8f048123cf44
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date: Tue May 26 10:11:22 2009 +0200
Couple of memory fixes
---
bank/bank-argument.c | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/bank/bank-argument.c b/bank/bank-argument.c
index 76745d4..44495fb 100644
--- a/bank/bank-argument.c
+++ b/bank/bank-argument.c
@@ -261,7 +261,7 @@ pyg_argument_to_pyobject(GArgument *arg, GITypeInfo *type_info)
return NULL;
}
- obj = PyObject_New(PyObject, (PyTypeObject *) tp);
+ obj = PyObject_GC_New(PyObject, (PyTypeObject *) tp);
if (obj == NULL)
return NULL;
@@ -279,22 +279,18 @@ pyg_argument_to_pyobject(GArgument *arg, GITypeInfo *type_info)
obj = Py_None;
} else if ( arg->v_pointer == NULL ) {
obj = Py_None;
- Py_INCREF(obj);
- return obj;
} else {
GValue value;
- GObject* obj = arg->v_pointer;
- GType gtype = G_OBJECT_TYPE(obj);
+ GObject* gobj = arg->v_pointer;
+ GType gtype = G_OBJECT_TYPE(gobj);
GIRepository *repo = g_irepository_get_default();
GIBaseInfo *object_info = g_irepository_find_by_gtype(repo, gtype);
const gchar *module_name;
const gchar *type_name;
- if (object_info == NULL) {
- // TODO: can we do something smarter here?
- g_warning("g_irepository_find_by_gtype failed to return an info for %s",
- g_type_name(gtype));
- } else {
+ if (object_info != NULL) {
+ // It's a pybank class, we should make sure it is initialized.
+
module_name = g_base_info_get_namespace(object_info);
type_name = g_base_info_get_name(object_info);
@@ -305,8 +301,8 @@ pyg_argument_to_pyobject(GArgument *arg, GITypeInfo *type_info)
}
value.g_type = gtype;
- value.data[0].v_pointer = obj;
- return pyg_value_as_pyobject(&value, FALSE);
+ value.data[0].v_pointer = gobj;
+ obj = pyg_value_as_pyobject(&value, FALSE);
}
break;
case GI_TYPE_TAG_ARRAY:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]