mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
plugin: Don't import modules that were already imported.
This avoids warnings for the cases where pygst.require() was already called.
This commit is contained in:
parent
3f5c8795c3
commit
6d6781e01f
1 changed files with 23 additions and 13 deletions
|
@ -252,23 +252,33 @@ pygst_require (gchar * version)
|
||||||
{
|
{
|
||||||
PyObject *pygst, *gst;
|
PyObject *pygst, *gst;
|
||||||
PyObject *require;
|
PyObject *require;
|
||||||
|
PyObject *modules;
|
||||||
|
|
||||||
|
modules = PySys_GetObject ("modules");
|
||||||
|
/* Try to see if 'gst' is already imported */
|
||||||
|
if (!(gst = PyMapping_GetItemString (modules, "gst"))) {
|
||||||
|
|
||||||
|
/* if not, see if 'pygst' was already imported. If so, we assume that
|
||||||
|
* 'pygst.require' has already been called. */
|
||||||
|
if (!(pygst = PyMapping_GetItemString (modules, "pygst"))) {
|
||||||
if (!(pygst = PyImport_ImportModule ("pygst"))) {
|
if (!(pygst = PyImport_ImportModule ("pygst"))) {
|
||||||
GST_ERROR ("the pygst module is not available!");
|
GST_ERROR ("the pygst module is not available!");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(PyObject_CallMethod (pygst, "require", "s", version))) {
|
if (!(PyObject_CallMethod (pygst, "require", "s", version))) {
|
||||||
GST_ERROR ("the required version, %s, of gst-python is not available!");
|
GST_ERROR ("the required version, %s, of gst-python is not available!",
|
||||||
|
version);
|
||||||
Py_DECREF (pygst);
|
Py_DECREF (pygst);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!(gst = PyImport_ImportModule ("gst"))) {
|
if (!(gst = PyImport_ImportModule ("gst"))) {
|
||||||
GST_ERROR ("couldn't import the gst module");
|
GST_ERROR ("couldn't import the gst module");
|
||||||
Py_DECREF (pygst);
|
Py_DECREF (pygst);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#define IMPORT(x, y) \
|
#define IMPORT(x, y) \
|
||||||
_PyGst##x##_Type = (PyTypeObject *)PyObject_GetAttrString(gst, y); \
|
_PyGst##x##_Type = (PyTypeObject *)PyObject_GetAttrString(gst, y); \
|
||||||
if (_PyGst##x##_Type == NULL) { \
|
if (_PyGst##x##_Type == NULL) { \
|
||||||
|
|
Loading…
Reference in a new issue