validate: Properly clear the overrides registry on deinit

Summary: Depends on D208

Reviewers: Mathieu_Du

Differential Revision: http://phabricator.freedesktop.org/D209
This commit is contained in:
Thibault Saunier 2015-05-26 18:45:45 +02:00
parent 2c6993b2bd
commit 6ddf55eaa2
3 changed files with 57 additions and 0 deletions

View file

@ -43,5 +43,6 @@ void init_scenarios (void);
* and this is done by the scenario itself now */
GST_EXPORT gboolean _action_check_and_set_printed (GstValidateAction *action);
GST_EXPORT gboolean gst_validate_action_is_subaction (GstValidateAction *action);
void _priv_validate_override_registry_deinit (void);
#endif

View file

@ -57,6 +57,25 @@ static GstValidateOverrideRegistry *_registry_default = NULL;
#define GST_VALIDATE_OVERRIDE_INIT_SYMBOL "gst_validate_create_overrides"
typedef int (*GstValidateCreateOverride) (void);
static void
gst_validate_override_registry_name_entry_free
(GstValidateOverrideRegistryNameEntry * entry)
{
g_free (entry->name);
gst_object_unref (entry->override);
g_slice_free (GstValidateOverrideRegistryNameEntry, entry);
}
static void
gst_validate_override_registry_type_entry_free
(GstValidateOverrideRegistryGTypeEntry * entry)
{
gst_object_unref (entry->override);
g_slice_free (GstValidateOverrideRegistryGTypeEntry, entry);
}
static GstValidateOverrideRegistry *
gst_validate_override_registry_new (void)
{
@ -70,6 +89,25 @@ gst_validate_override_registry_new (void)
return reg;
}
static void
gst_validate_overide_registery_free (GstValidateOverrideRegistry * reg)
{
g_queue_foreach (&reg->klass_overrides,
(GFunc) gst_validate_override_registry_name_entry_free, NULL);
g_queue_foreach (&reg->name_overrides,
(GFunc) gst_validate_override_registry_name_entry_free, NULL);
g_queue_foreach (&reg->gtype_overrides,
(GFunc) gst_validate_override_registry_type_entry_free, NULL);
g_queue_clear (&reg->name_overrides);
g_queue_clear (&reg->gtype_overrides);
g_queue_clear (&reg->klass_overrides);
g_slice_free (GstValidateOverrideRegistry, reg);
}
GstValidateOverrideRegistry *
gst_validate_override_registry_get (void)
{
@ -407,3 +445,19 @@ GList *gst_validate_override_registry_get_override_for_names
return ret;
}
void
_priv_validate_override_registry_deinit (void)
{
GstValidateOverrideRegistry *reg = NULL;
g_mutex_lock (&_gst_validate_override_registry_mutex);
if (G_UNLIKELY (_registry_default)) {
reg = _registry_default;
_registry_default = NULL;
}
g_mutex_unlock (&_gst_validate_override_registry_mutex);
if (reg)
gst_validate_overide_registery_free (reg);
}

View file

@ -267,6 +267,8 @@ void
gst_validate_deinit (void)
{
_free_plugin_config (core_config);
gst_object_unref (_gst_validate_registry_default);
_priv_validate_override_registry_deinit ();
core_config = NULL;
validate_initialized = FALSE;
}