summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-11-16 10:12:37 +0200
committerSebastian Dröge <sebastian@centricular.com>2015-11-16 10:12:37 +0200
commit4097d3df3cc4c6c0495a805fe16a7d3d456903b0 (patch)
treec55da429b894553504d1d7da7277923c36845d9a /plugin
parent9352c54ced630064779d38614e560309482a3829 (diff)
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.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/gstpythonplugin.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/plugin/gstpythonplugin.c b/plugin/gstpythonplugin.c
index 32b7405..f5e02eb 100644
--- a/plugin/gstpythonplugin.c
+++ b/plugin/gstpythonplugin.c
@@ -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;
}
}