mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-23 04:36:17 +01:00
GSettings: two memory use fixes
First, correct a rather dubious case of accessing a GSettingsSchemaKey after clearing it. This was technically okay because only the key name was accessed (and it is not owned by the struct) but it looks very wrong. Second, have g_settings_backend_write() sink the passed in GVariant*. Not all backends get this right, and I'm starting to like the pattern of virtual function wrappers being responsible for sinking the parameters that they are documented as consuming.
This commit is contained in:
parent
8e763aef43
commit
da386705f9
@ -1322,6 +1322,7 @@ g_settings_set_value (GSettings *settings,
|
||||
GVariant *value)
|
||||
{
|
||||
GSettingsSchemaKey skey;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (G_IS_SETTINGS (settings), FALSE);
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
@ -1349,9 +1350,10 @@ g_settings_set_value (GSettings *settings,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
success = g_settings_write_to_backend (settings, &skey, value);
|
||||
g_settings_schema_key_clear (&skey);
|
||||
|
||||
return g_settings_write_to_backend (settings, &skey, value);
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -772,8 +772,14 @@ g_settings_backend_write (GSettingsBackend *backend,
|
||||
GVariant *value,
|
||||
gpointer origin_tag)
|
||||
{
|
||||
return G_SETTINGS_BACKEND_GET_CLASS (backend)
|
||||
gboolean success;
|
||||
|
||||
g_variant_ref_sink (value);
|
||||
success = G_SETTINGS_BACKEND_GET_CLASS (backend)
|
||||
->write (backend, key, value, origin_tag);
|
||||
g_variant_unref (value);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
|
Loading…
Reference in New Issue
Block a user