[glib: 5/6] gsettings: Drop internal delayed member
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 5/6] gsettings: Drop internal delayed member
- Date: Wed, 3 Nov 2021 18:03:22 +0000 (UTC)
commit 44cbba5d78f7cf166498436f513edb5b9e02e13d
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue Oct 26 14:29:31 2021 +0100
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
gio/gsettings.c | 36 ++++++++++++------------------------
1 file changed, 12 insertions(+), 24 deletions(-)
---
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 711929cff..e96c94e11 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -343,8 +343,6 @@ struct _GSettingsPrivate
GSettingsBackend *backend;
GSettingsSchema *schema;
gchar *path;
-
- GDelayedSettingsBackend *delayed;
};
enum
@@ -604,11 +602,6 @@ 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:
@@ -647,7 +640,7 @@ g_settings_get_property (GObject *object,
break;
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;
default:
@@ -685,13 +678,7 @@ g_settings_constructed (GObject *object)
}
if (settings->priv->backend == NULL)
- {
- 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));
- }
+ settings->priv->backend = g_settings_backend_get_default ();
g_settings_backend_watch (settings->priv->backend,
&listener_vtable, G_OBJECT (settings),
@@ -2267,19 +2254,20 @@ g_settings_set_strv (GSettings *settings,
void
g_settings_delay (GSettings *settings)
{
+ GDelayedSettingsBackend *delayed = NULL;
+
g_return_if_fail (G_IS_SETTINGS (settings));
- if (settings->priv->delayed)
+ if (G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend))
return;
- settings->priv->delayed =
- g_delayed_settings_backend_new (settings->priv->backend,
- settings,
- settings->priv->main_context);
+ delayed = g_delayed_settings_backend_new (settings->priv->backend,
+ settings,
+ settings->priv->main_context);
g_settings_backend_unwatch (settings->priv->backend, G_OBJECT (settings));
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,
&listener_vtable, G_OBJECT (settings),
settings->priv->main_context);
@@ -2299,7 +2287,7 @@ g_settings_delay (GSettings *settings)
void
g_settings_apply (GSettings *settings)
{
- if (settings->priv->delayed)
+ if (G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend))
{
GDelayedSettingsBackend *delayed;
@@ -2322,7 +2310,7 @@ g_settings_apply (GSettings *settings)
void
g_settings_revert (GSettings *settings)
{
- if (settings->priv->delayed)
+ if (G_IS_DELAYED_SETTINGS_BACKEND (settings->priv->backend))
{
GDelayedSettingsBackend *delayed;
@@ -2347,7 +2335,7 @@ g_settings_get_has_unapplied (GSettings *settings)
{
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 (settings->priv->backend));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]