Merge branch 'settings-test-cleanups-subset' into 'master'

Various memory leak cleanups to GSettings tests (subset)

See merge request GNOME/glib!629
This commit is contained in:
Simon McVittie 2019-01-30 18:56:28 +00:00
commit 52b8947bf6
6 changed files with 64 additions and 3 deletions

View File

@ -225,6 +225,10 @@ get_from_keyfile (GKeyfileSettingsBackend *kfsb,
if (str)
{
return_value = g_variant_parse (type, str, NULL, NULL, NULL);
/* As a special case, support values of type %G_VARIANT_TYPE_STRING
* not being quoted, since users keep forgetting to do it and then
* getting confused. */
if (return_value == NULL &&
g_variant_type_equal (type, G_VARIANT_TYPE_STRING) &&
str[0] != '\"')

View File

@ -1137,6 +1137,8 @@ g_settings_new_full (GSettingsSchema *schema,
}
/* Internal read/write utilities {{{1 */
/* @value will be sunk */
static gboolean
g_settings_write_to_backend (GSettings *settings,
GSettingsSchemaKey *key,
@ -1417,7 +1419,7 @@ g_settings_set_enum (GSettings *settings,
return FALSE;
}
success = g_settings_write_to_backend (settings, &skey, variant);
success = g_settings_write_to_backend (settings, &skey, g_steal_pointer (&variant));
g_settings_schema_key_clear (&skey);
return success;
@ -1528,7 +1530,7 @@ g_settings_set_flags (GSettings *settings,
return FALSE;
}
success = g_settings_write_to_backend (settings, &skey, variant);
success = g_settings_write_to_backend (settings, &skey, g_steal_pointer (&variant));
g_settings_schema_key_clear (&skey);
return success;
@ -1672,7 +1674,7 @@ g_settings_set (GSettings *settings,
value = g_variant_new_va (format, NULL, &ap);
va_end (ap);
return g_settings_set_value (settings, key, value);
return g_settings_set_value (settings, key, g_steal_pointer (&value));
}
/**

View File

@ -777,6 +777,8 @@ g_settings_backend_read_user_value (GSettingsBackend *backend,
* to indicate that the affected keys have suddenly "changed back" to their
* old values.
*
* If @value has a floating reference, it will be sunk.
*
* Returns: %TRUE if the write succeeded, %FALSE if the key was not writable
*/
gboolean
@ -1050,5 +1052,7 @@ g_settings_backend_sync_default (void)
if (class->sync)
class->sync (backend);
g_object_unref (backend);
}
}

View File

@ -1472,6 +1472,7 @@ g_settings_schema_key_to_enum (GSettingsSchemaKey *key,
return result;
}
/* Returns a new floating #GVariant. */
GVariant *
g_settings_schema_key_from_enum (GSettingsSchemaKey *key,
gint value)
@ -1511,6 +1512,7 @@ g_settings_schema_key_to_flags (GSettingsSchemaKey *key,
return result;
}
/* Returns a new floating #GVariant. */
GVariant *
g_settings_schema_key_from_flags (GSettingsSchemaKey *key,
guint value)

View File

@ -2442,6 +2442,7 @@ test_schema_source (void)
g_settings_schema_unref (schema);
g_settings_schema_source_unref (source);
g_object_unref (backend);
}
static void

View File

@ -228,6 +228,16 @@
fun:_g_io_module_get_default
}
{
g-io-module-default-singleton-name
Memcheck:Leak
fun:malloc
...
fun:g_strdup
...
fun:_g_io_module_get_default*
}
{
g-get-language-names-malloc
Memcheck:Leak
@ -676,3 +686,41 @@
fun:g_queue_new
fun:g_main_context_push_thread_default
}
# One-time allocations for #GFileInfo attribute cache
{
g_file_info_attribute_cache
Memcheck:Leak
fun:malloc
...
fun:ensure_attribute_hash
...
fun:g_file_*
}
{
g_file_info_attribute_cache2
Memcheck:Leak
fun:calloc
...
fun:ensure_attribute_hash
...
fun:g_file_*
}
{
g_file_info_attribute_cache3
Memcheck:Leak
fun:malloc
...
fun:lookup_namespace
...
fun:g_file_*
}
{
g_file_info_attribute_cache4
Memcheck:Leak
fun:calloc
...
fun:lookup_namespace
...
fun:g_file_*
}