mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 22:46:15 +01:00
gsettings: Clarify that g_settings_get_child() inherits delay-apply
Previously, the delay-apply status of the parent `GSettings` object would be partially inherited: `settings->priv->backend` in the child `GSettings` object would point to a `GDelayedSettingsBackend`, but `settings->priv->delayed` would be `NULL`. The expectation from https://bugzilla.gnome.org/show_bug.cgi?id=720891 was that `get_child()` would fully inherit delay-apply status. So, ensure that `settings->priv->delayed` is correctly set to point to the delayed backend when constructing any `GSettings`. Update the tests to work again (presumably the inverted test was an oversight in the original changes). Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2426
This commit is contained in:
parent
3db22ab8db
commit
0101ccba16
@ -604,6 +604,11 @@ g_settings_set_property (GObject *object,
|
||||
|
||||
case PROP_BACKEND:
|
||||
settings->priv->backend = g_value_dup_object (value);
|
||||
if (G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend))
|
||||
{
|
||||
g_assert (settings->priv->delayed == NULL);
|
||||
settings->priv->delayed = G_DELAYED_SETTINGS_BACKEND (settings->priv->backend);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -680,7 +685,13 @@ g_settings_constructed (GObject *object)
|
||||
}
|
||||
|
||||
if (settings->priv->backend == NULL)
|
||||
settings->priv->backend = g_settings_backend_get_default ();
|
||||
{
|
||||
settings->priv->backend = g_settings_backend_get_default ();
|
||||
|
||||
/* The default had better not be delayed, otherwise we also need to set
|
||||
* settings->priv->delayed. */
|
||||
g_assert (!G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend));
|
||||
}
|
||||
|
||||
g_settings_backend_watch (settings->priv->backend,
|
||||
&listener_vtable, G_OBJECT (settings),
|
||||
@ -2426,6 +2437,9 @@ g_settings_is_writable (GSettings *settings,
|
||||
* The schema for the child settings object must have been declared
|
||||
* in the schema of @settings using a `<child>` element.
|
||||
*
|
||||
* The created child settings object will inherit the #GSettings:delay-apply
|
||||
* mode from @settings.
|
||||
*
|
||||
* Returns: (not nullable) (transfer full): a 'child' settings object
|
||||
*
|
||||
* Since: 2.26
|
||||
|
@ -619,7 +619,7 @@ test_delay_child (void)
|
||||
g_assert_nonnull (child);
|
||||
|
||||
g_object_get (child, "delay-apply", &delay, NULL);
|
||||
g_assert_false (delay);
|
||||
g_assert_true (delay);
|
||||
|
||||
g_settings_get (child, "test-byte", "y", &byte);
|
||||
g_assert_cmpuint (byte, ==, 36);
|
||||
@ -630,6 +630,11 @@ test_delay_child (void)
|
||||
g_settings_get (base, "test-byte", "y", &byte);
|
||||
g_assert_cmpuint (byte, ==, 36);
|
||||
|
||||
/* apply the child and the changes should be saved */
|
||||
g_settings_apply (child);
|
||||
g_settings_get (base, "test-byte", "y", &byte);
|
||||
g_assert_cmpuint (byte, ==, 42);
|
||||
|
||||
g_object_unref (child);
|
||||
g_object_unref (settings);
|
||||
g_object_unref (base);
|
||||
|
Loading…
Reference in New Issue
Block a user