gst/gstelementfactory.c: If the GstElementClass doesn't have a GstElementDetails with all fields then error out nicel...

Original commit message from CVS:
* gst/gstelementfactory.c: (gst_element_register):
If the GstElementClass doesn't have a GstElementDetails with all fields
filled up correctly (longname, description AND author), then error out
nicely instead of crashing.
This commit is contained in:
Edward Hervey 2006-08-14 15:33:17 +00:00
parent 5f0bc06ae1
commit b2bfb935b2
2 changed files with 23 additions and 4 deletions

View file

@ -1,3 +1,10 @@
2006-08-14 Edward Hervey <edward@fluendo.com>
* gst/gstelementfactory.c: (gst_element_register):
If the GstElementClass doesn't have a GstElementDetails with all fields
filled up correctly (longname, description AND author), then error out
nicely instead of crashing.
2006-08-14 Tim-Philipp Müller <tim at centricular dot net>
* gst/gststructure.c:

View file

@ -271,6 +271,10 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
g_type_name (type));
klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
if ((klass->details.longname == NULL) ||
(klass->details.klass == NULL) || (klass->details.author == NULL))
goto detailserror;
factory->type = type;
__gst_element_details_copy (&factory->details, &klass->details);
for (item = klass->padtemplates; item; item = item->next) {
@ -294,13 +298,13 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
g_type_interface_peek (klass, GST_TYPE_URI_HANDLER);
if (!iface || !iface->get_type || !iface->get_protocols)
goto error;
goto urierror;
factory->uri_type = iface->get_type ();
if (!GST_URI_TYPE_IS_VALID (factory->uri_type))
goto error;
goto urierror;
factory->uri_protocols = g_strdupv (iface->get_protocols ());
if (!factory->uri_protocols)
goto error;
goto urierror;
}
interfaces = g_type_interfaces (type, &n_interfaces);
@ -319,12 +323,20 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
return TRUE;
/* ERRORS */
error:
urierror:
{
GST_WARNING_OBJECT (factory, "error with uri handler!");
gst_element_factory_cleanup (factory);
return FALSE;
}
detailserror:
{
GST_WARNING_OBJECT (factory,
"The GstElementDetails don't seem to have been set properly");
gst_element_factory_cleanup (factory);
return FALSE;
}
}
/**