mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-08 04:41:31 +00:00
leaks: Handle subclasses in filters even for unhandled/lazy loaded types
Using typename in the set of unhandled types instead of the quark so that we also handle subclasses as with other filters.
This commit is contained in:
parent
e3ab5e4df9
commit
bd73551cc0
2 changed files with 27 additions and 19 deletions
|
@ -139,10 +139,10 @@ set_filters (GstLeaksTracer * self, const gchar * filters)
|
||||||
* should_handle_object_type() when/if the object type is actually
|
* should_handle_object_type() when/if the object type is actually
|
||||||
* used. */
|
* used. */
|
||||||
if (!self->unhandled_filter)
|
if (!self->unhandled_filter)
|
||||||
self->unhandled_filter = g_hash_table_new (NULL, NULL);
|
self->unhandled_filter = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
|
g_free, NULL);
|
||||||
|
|
||||||
g_hash_table_add (self->unhandled_filter,
|
g_hash_table_add (self->unhandled_filter, g_strdup (tmp[i]));
|
||||||
GUINT_TO_POINTER (g_quark_from_string (tmp[i])));
|
|
||||||
g_atomic_int_inc (&self->unhandled_filter_count);
|
g_atomic_int_inc (&self->unhandled_filter_count);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,23 @@ set_stacktrace:
|
||||||
gst_structure_free (params_struct);
|
gst_structure_free (params_struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_expand_unhandled_filters (gchar * typename, gpointer unused_value,
|
||||||
|
GstLeaksTracer * self)
|
||||||
|
{
|
||||||
|
GType type;
|
||||||
|
|
||||||
|
type = g_type_from_name (typename);
|
||||||
|
|
||||||
|
if (type == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
g_atomic_int_dec_and_test (&self->unhandled_filter_count);
|
||||||
|
g_array_append_val (self->filter, type);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
should_handle_object_type (GstLeaksTracer * self, GType object_type)
|
should_handle_object_type (GstLeaksTracer * self, GType object_type)
|
||||||
{
|
{
|
||||||
|
@ -202,23 +219,14 @@ should_handle_object_type (GstLeaksTracer * self, GType object_type)
|
||||||
/* No filtering, handle all types */
|
/* No filtering, handle all types */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
if (object_type == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
|
||||||
if (g_atomic_int_get (&self->unhandled_filter_count)) {
|
if (g_atomic_int_get (&self->unhandled_filter_count)) {
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
if (self->unhandled_filter) {
|
g_hash_table_foreach_remove (self->unhandled_filter,
|
||||||
GQuark q;
|
(GHRFunc) _expand_unhandled_filters, self);
|
||||||
|
|
||||||
q = g_type_qname (object_type);
|
|
||||||
if (g_hash_table_contains (self->unhandled_filter, GUINT_TO_POINTER (q))) {
|
|
||||||
g_array_append_val (self->filter, object_type);
|
|
||||||
g_hash_table_remove (self->unhandled_filter, GUINT_TO_POINTER (q));
|
|
||||||
|
|
||||||
if (g_atomic_int_dec_and_test (&self->unhandled_filter_count))
|
|
||||||
g_clear_pointer (&self->unhandled_filter, g_hash_table_unref);
|
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (self);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ struct _GstLeaksTracer {
|
||||||
GHashTable *added;
|
GHashTable *added;
|
||||||
/* Set of owned ObjectLog. Protected by object lock */
|
/* Set of owned ObjectLog. Protected by object lock */
|
||||||
GHashTable *removed;
|
GHashTable *removed;
|
||||||
/* If not NULL, contain a set of GQuark representing type filter not
|
/* If not NULL, contain a set of string representing type filter not
|
||||||
* (yet?) known by the type system.
|
* (yet?) known by the type system.
|
||||||
* Protected by object lock. */
|
* Protected by object lock. */
|
||||||
GHashTable *unhandled_filter;
|
GHashTable *unhandled_filter;
|
||||||
|
|
Loading…
Reference in a new issue