Skip to content
Snippets Groups Projects
Commit 4097d3df authored by Sebastian Dröge's avatar Sebastian Dröge :tea:
Browse files

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.
parent 9352c54c
No related branches found
No related tags found
No related merge requests found
......@@ -239,7 +239,7 @@ plugin_init (GstPlugin * plugin)
g_module_open (PY_LIB_LOC "/libpython" PYTHON_VERSION PY_ABI_FLAGS
"." PY_LIB_SUFFIX, 0);
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 ());
return FALSE;
}
......@@ -257,20 +257,25 @@ plugin_init (GstPlugin * plugin)
GST_LOG ("initializing pygobject");
if (!pygobject_init (3, 0, 0)) {
GST_WARNING ("pygobject initialization failed");
g_critical ("pygobject initialization failed");
return FALSE;
}
gst = PyImport_ImportModule ("gi.repository.Gst");
if (!gst) {
g_critical ("can't find gi.repository.Gst");
return FALSE;
}
if (we_initialized) {
PyObject *tmp;
dict = PyModule_GetDict (gst);
if (!dict) {
GST_ERROR ("no dict?!");
g_critical ("gi.repository.Gst is no dict");
return FALSE;
}
tmp =
PyObject_GetAttr (PyMapping_GetItemString (dict,
"_introspection_module"), PyUnicode_FromString ("__dict__"));
......@@ -278,13 +283,15 @@ plugin_init (GstPlugin * plugin)
_PyGstElement_Type = PyMapping_GetItemString (tmp, "Element");
if (!_PyGstElement_Type) {
g_error ("Could not get Gst.Element");
Py_DECREF (pyplugin);
g_critical ("Could not get Gst.Element");
return FALSE;
}
pyplugin = pygobject_new (G_OBJECT (plugin));
if (!pyplugin || PyModule_AddObject (gst, "__plugin__", pyplugin) != 0) {
g_warning ("Couldn't set plugin");
g_critical ("Couldn't set __plugin__ attribute");
Py_DECREF (pyplugin);
return FALSE;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment