From: <tho...@fr...> - 2005-09-13 09:48:47
|
CVS Root: /cvs/gstreamer Module: gst-python Changes by: thomasvs Date: Tue Sep 13 2005 02:48:44 PDT Log message: fix wrong decrefs Modified files: . : ChangeLog gst : gstbus.override Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/ChangeLog.diff?r1=1.233&r2=1.234 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gstbus.override.diff?r1=1.4&r2=1.5 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-python/ChangeLog,v retrieving revision 1.233 retrieving revision 1.234 diff -u -d -r1.233 -r1.234 --- ChangeLog 12 Sep 2005 18:19:08 -0000 1.233 +++ ChangeLog 13 Sep 2005 09:48:32 -0000 1.234 @@ -1,3 +1,8 @@ +2005-09-13 Thomas Vander Stichele <thomas at apestaart dot org> + + * gst/gstbus.override: + fix wrong decrefs 2005-09-12 Thomas Vander Stichele <thomas at apestaart dot org> * gst/gst.defs: Index: gstbus.override RCS file: /cvs/gstreamer/gst-python/gst/gstbus.override,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstbus.override 13 Sep 2005 08:52:49 -0000 1.4 +++ gstbus.override 13 Sep 2005 09:48:32 -0000 1.5 @@ -32,43 +32,48 @@ PyObject *py_msg; PyObject *callback, *args; PyObject *ret; - gint i,len; + gint i, len; g_return_val_if_fail (user_data != NULL, GST_BUS_PASS); - state = pyg_gil_state_ensure(); + state = pyg_gil_state_ensure (); py_userdata = (PyObject *) user_data; - py_msg = pygstminiobject_new(GST_MINI_OBJECT(message)); - callback = PyTuple_GetItem(py_userdata, 0); - args = Py_BuildValue("(NN)", - pygobject_new(G_OBJECT(bus)), - py_msg); + py_msg = pygstminiobject_new (GST_MINI_OBJECT (message)); + callback = PyTuple_GetItem (py_userdata, 0); - len = PyTuple_Size(py_userdata); + /* Using N we give away our references to the args tuple */ + args = Py_BuildValue ("(NN)", + pygobject_new (G_OBJECT (bus)), + py_msg); + /* add all *args to the args tuple object */ + len = PyTuple_Size (py_userdata); for (i = 1; i < len; ++i) { PyObject *tuple = args; - args = PySequence_Concat(tuple, PyTuple_GetItem(py_userdata, i)); - Py_DECREF(tuple); + args = PySequence_Concat (tuple, PyTuple_GetItem (py_userdata, i)); + Py_DECREF (tuple); } - ret = PyObject_CallObject(callback, args); + ret = PyObject_CallObject (callback, args); if (!ret) { - PyErr_Print(); + PyErr_Print (); res = GST_BUS_PASS; } else { if (ret == Py_None) { - PyErr_SetString(PyExc_TypeError, "callback should return a BusSyncReply"); - PyErr_Print(); + PyErr_SetString (PyExc_TypeError, + "callback should return a BusSyncReply"); + PyErr_Print (); res = GST_BUS_PASS; - } else if (pyg_enum_get_value(GST_TYPE_BUS_SYNC_REPLY, ret, (gint *) &res)) + } else if (pyg_enum_get_value (GST_TYPE_BUS_SYNC_REPLY, ret, + (gint *) &res)) res = GST_BUS_PASS; Py_DECREF (ret); - Py_DECREF(py_msg); - Py_DECREF(args); + Py_DECREF (args); - pyg_gil_state_release(state); + pyg_gil_state_release (state); return res; } @@ -79,46 +84,49 @@ PyGILState_STATE state; gboolean res; PyObject *py_userdata; - PyObject *py_msg; + PyObject *py_msg; g_return_val_if_fail (user_data != NULL, TRUE); - py_msg = pygstminiobject_new(GST_MINI_OBJECT(message)); ret = PyObject_CallObject(callback, args); res = TRUE; - PyErr_SetString(PyExc_TypeError, "callback should return True or False"); + "callback should return True or False"); res = TRUE; } else - res = PyObject_IsTrue(ret); - Py_DECREF(ret); + res = PyObject_IsTrue (ret); + Py_DECREF (ret); |