From abe5953fb911bad7eb47a6d1180f25c6e1700f1d Mon Sep 17 00:00:00 2001 From: Zaheer Abbas Merali Date: Mon, 9 Jul 2007 19:30:26 +0000 Subject: [PATCH] gst/gstevent.override: Copy the GstStructure given as argument to gst_event_new_custom and gst_event_new_navigation, ... Original commit message from CVS: Patch by: Zaheer Abbas Merali * gst/gstevent.override: Copy the GstStructure given as argument to gst_event_new_custom and gst_event_new_navigation, else it would be freed when the python object wrapping that structure goes out of scope. Fixes #450117 --- ChangeLog | 9 +++++++++ gst/gstevent.override | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/ChangeLog b/ChangeLog index 713f843..94500c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-07-09 Edward Hervey + + Patch by: Zaheer Abbas Merali + * gst/gstevent.override: + Copy the GstStructure given as argument to gst_event_new_custom + and gst_event_new_navigation, else it would be freed when the python + object wrapping that structure goes out of scope. + Fixes #450117 + 2007-07-05 Edward Hervey Patch by: Rene Stadler diff --git a/gst/gstevent.override b/gst/gstevent.override index ba498fc..516963f 100644 --- a/gst/gstevent.override +++ b/gst/gstevent.override @@ -180,3 +180,58 @@ _wrap_gst_event_parse_latency (PyGstMiniObject * self) return PyLong_FromUnsignedLongLong(ctime); } +%% +override gst_event_new_navigation kwargs +static PyObject * +_wrap_gst_event_new_navigation(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "structure", NULL }; + PyObject *py_structure, *py_ret; + GstEvent *ret; + GstStructure *structure = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:event_new_navigation", kwlist, &py_structure)) + return NULL; + if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE)) + structure = pyg_boxed_get(py_structure, GstStructure); + else { + PyErr_SetString(PyExc_TypeError, "structure should be a GstStructure"); + return NULL; + } + pyg_begin_allow_threads; + ret = gst_event_new_navigation(gst_structure_copy(structure)); + pyg_end_allow_threads; + py_ret = pygstminiobject_new((GstMiniObject *)ret); + if (ret != NULL) + gst_mini_object_unref((GstMiniObject *)ret); + return py_ret; +} +%% +override gst_event_new_custom kwargs +static PyObject * +_wrap_gst_event_new_custom(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "type", "structure", NULL }; + PyObject *py_type = NULL, *py_structure, *py_ret; + GstEvent *ret; + GstStructure *structure = NULL; + GstEventType type; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:event_new_custom", kwlist, &py_type, &py_structure)) + return NULL; + if (pyg_enum_get_value(GST_TYPE_EVENT_TYPE, py_type, (gint *)&type)) + return NULL; + if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE)) + structure = pyg_boxed_get(py_structure, GstStructure); + else { + PyErr_SetString(PyExc_TypeError, "structure should be a GstStructure"); + return NULL; + } + pyg_begin_allow_threads; + ret = gst_event_new_custom(type, gst_structure_copy(structure)); + pyg_end_allow_threads; + py_ret = pygstminiobject_new((GstMiniObject *)ret); + if (ret != NULL) + gst_mini_object_unref((GstMiniObject *)ret); + return py_ret; +} -- 2.7.4