gsettings: Drop internal delayed member

This introduces no functional changes; it only simplifies the code.

Instead of maintaining a separate pointer to the backend iff it’s a
`GDelayedSettingsBackend`, just test the `backend` pointer’s type.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2426
This commit is contained in:
Philip Withnall 2021-10-26 14:29:31 +01:00
parent 0101ccba16
commit 44cbba5d78

View File

@ -343,8 +343,6 @@ struct _GSettingsPrivate
GSettingsBackend *backend; GSettingsBackend *backend;
GSettingsSchema *schema; GSettingsSchema *schema;
gchar *path; gchar *path;
GDelayedSettingsBackend *delayed;
}; };
enum enum
@ -604,11 +602,6 @@ g_settings_set_property (GObject *object,
case PROP_BACKEND: case PROP_BACKEND:
settings->priv->backend = g_value_dup_object (value); 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; break;
default: default:
@ -647,7 +640,7 @@ g_settings_get_property (GObject *object,
break; break;
case PROP_DELAY_APPLY: case PROP_DELAY_APPLY:
g_value_set_boolean (value, settings->priv->delayed != NULL); g_value_set_boolean (value, G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend));
break; break;
default: default:
@ -685,13 +678,7 @@ g_settings_constructed (GObject *object)
} }
if (settings->priv->backend == NULL) 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, g_settings_backend_watch (settings->priv->backend,
&listener_vtable, G_OBJECT (settings), &listener_vtable, G_OBJECT (settings),
@ -2267,19 +2254,20 @@ g_settings_set_strv (GSettings *settings,
void void
g_settings_delay (GSettings *settings) g_settings_delay (GSettings *settings)
{ {
GDelayedSettingsBackend *delayed = NULL;
g_return_if_fail (G_IS_SETTINGS (settings)); g_return_if_fail (G_IS_SETTINGS (settings));
if (settings->priv->delayed) if (G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend))
return; return;
settings->priv->delayed = delayed = g_delayed_settings_backend_new (settings->priv->backend,
g_delayed_settings_backend_new (settings->priv->backend, settings,
settings, settings->priv->main_context);
settings->priv->main_context);
g_settings_backend_unwatch (settings->priv->backend, G_OBJECT (settings)); g_settings_backend_unwatch (settings->priv->backend, G_OBJECT (settings));
g_object_unref (settings->priv->backend); g_object_unref (settings->priv->backend);
settings->priv->backend = G_SETTINGS_BACKEND (settings->priv->delayed); settings->priv->backend = G_SETTINGS_BACKEND (delayed);
g_settings_backend_watch (settings->priv->backend, g_settings_backend_watch (settings->priv->backend,
&listener_vtable, G_OBJECT (settings), &listener_vtable, G_OBJECT (settings),
settings->priv->main_context); settings->priv->main_context);
@ -2299,7 +2287,7 @@ g_settings_delay (GSettings *settings)
void void
g_settings_apply (GSettings *settings) g_settings_apply (GSettings *settings)
{ {
if (settings->priv->delayed) if (G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend))
{ {
GDelayedSettingsBackend *delayed; GDelayedSettingsBackend *delayed;
@ -2322,7 +2310,7 @@ g_settings_apply (GSettings *settings)
void void
g_settings_revert (GSettings *settings) g_settings_revert (GSettings *settings)
{ {
if (settings->priv->delayed) if (G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend))
{ {
GDelayedSettingsBackend *delayed; GDelayedSettingsBackend *delayed;
@ -2347,7 +2335,7 @@ g_settings_get_has_unapplied (GSettings *settings)
{ {
g_return_val_if_fail (G_IS_SETTINGS (settings), FALSE); g_return_val_if_fail (G_IS_SETTINGS (settings), FALSE);
return settings->priv->delayed && return G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend) &&
g_delayed_settings_backend_get_has_unapplied ( g_delayed_settings_backend_get_has_unapplied (
G_DELAYED_SETTINGS_BACKEND (settings->priv->backend)); G_DELAYED_SETTINGS_BACKEND (settings->priv->backend));
} }