mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
pythonplugin: Clean up error handling a bit
Don't g_error() but only g_critical() when things go wrong and return FALSE. g_error() would kill the application immediately. Also check if we can actually get gi.repository.Gst before using it.
This commit is contained in:
parent
9352c54ced
commit
4097d3df3c
1 changed files with 14 additions and 7 deletions
|
@ -239,7 +239,7 @@ plugin_init (GstPlugin * plugin)
|
||||||
g_module_open (PY_LIB_LOC "/libpython" PYTHON_VERSION PY_ABI_FLAGS
|
g_module_open (PY_LIB_LOC "/libpython" PYTHON_VERSION PY_ABI_FLAGS
|
||||||
"." PY_LIB_SUFFIX, 0);
|
"." PY_LIB_SUFFIX, 0);
|
||||||
if (!libpython) {
|
if (!libpython) {
|
||||||
GST_WARNING ("Couldn't g_module_open libpython. Reason: %s",
|
g_critical ("Couldn't g_module_open libpython. Reason: %s",
|
||||||
g_module_error ());
|
g_module_error ());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -257,20 +257,25 @@ plugin_init (GstPlugin * plugin)
|
||||||
|
|
||||||
GST_LOG ("initializing pygobject");
|
GST_LOG ("initializing pygobject");
|
||||||
if (!pygobject_init (3, 0, 0)) {
|
if (!pygobject_init (3, 0, 0)) {
|
||||||
GST_WARNING ("pygobject initialization failed");
|
g_critical ("pygobject initialization failed");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst = PyImport_ImportModule ("gi.repository.Gst");
|
gst = PyImport_ImportModule ("gi.repository.Gst");
|
||||||
|
if (!gst) {
|
||||||
|
g_critical ("can't find gi.repository.Gst");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (we_initialized) {
|
if (we_initialized) {
|
||||||
PyObject *tmp;
|
PyObject *tmp;
|
||||||
|
|
||||||
dict = PyModule_GetDict (gst);
|
dict = PyModule_GetDict (gst);
|
||||||
if (!dict) {
|
if (!dict) {
|
||||||
GST_ERROR ("no dict?!");
|
g_critical ("gi.repository.Gst is no dict");
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tmp =
|
tmp =
|
||||||
PyObject_GetAttr (PyMapping_GetItemString (dict,
|
PyObject_GetAttr (PyMapping_GetItemString (dict,
|
||||||
"_introspection_module"), PyUnicode_FromString ("__dict__"));
|
"_introspection_module"), PyUnicode_FromString ("__dict__"));
|
||||||
|
@ -278,13 +283,15 @@ plugin_init (GstPlugin * plugin)
|
||||||
_PyGstElement_Type = PyMapping_GetItemString (tmp, "Element");
|
_PyGstElement_Type = PyMapping_GetItemString (tmp, "Element");
|
||||||
|
|
||||||
if (!_PyGstElement_Type) {
|
if (!_PyGstElement_Type) {
|
||||||
g_error ("Could not get Gst.Element");
|
g_critical ("Could not get Gst.Element");
|
||||||
Py_DECREF (pyplugin);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pyplugin = pygobject_new (G_OBJECT (plugin));
|
pyplugin = pygobject_new (G_OBJECT (plugin));
|
||||||
if (!pyplugin || PyModule_AddObject (gst, "__plugin__", pyplugin) != 0) {
|
if (!pyplugin || PyModule_AddObject (gst, "__plugin__", pyplugin) != 0) {
|
||||||
g_warning ("Couldn't set plugin");
|
g_critical ("Couldn't set __plugin__ attribute");
|
||||||
Py_DECREF (pyplugin);
|
Py_DECREF (pyplugin);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue