mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-04 20:59:21 +02:00
delayed: fix issues found by test
gsettings: remove dead code test: don't leak in a way that causes test failures
This commit is contained in:
@@ -157,7 +157,8 @@ g_delayed_settings_backend_apply (GDelayedSettingsBackend *delayed)
|
|||||||
tmp, delayed->priv);
|
tmp, delayed->priv);
|
||||||
g_tree_unref (tmp);
|
g_tree_unref (tmp);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (delayed), "has-unapplied");
|
if (delayed->priv->owner)
|
||||||
|
g_object_notify (delayed->priv->owner, "has-unapplied");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +174,8 @@ g_delayed_settings_backend_revert (GDelayedSettingsBackend *delayed)
|
|||||||
g_settings_backend_changed_tree (G_SETTINGS_BACKEND (delayed), tmp, NULL);
|
g_settings_backend_changed_tree (G_SETTINGS_BACKEND (delayed), tmp, NULL);
|
||||||
g_tree_destroy (tmp);
|
g_tree_destroy (tmp);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (delayed), "has-unapplied");
|
if (delayed->priv->owner)
|
||||||
|
g_object_notify (delayed->priv->owner, "has-unapplied");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,7 +271,7 @@ g_delayed_settings_backend_class_init (GDelayedSettingsBackendClass *class)
|
|||||||
backend_class->reset_path = g_delayed_settings_backend_reset_path;
|
backend_class->reset_path = g_delayed_settings_backend_reset_path;
|
||||||
backend_class->get_writable = g_delayed_settings_backend_get_writable;
|
backend_class->get_writable = g_delayed_settings_backend_get_writable;
|
||||||
backend_class->subscribe = g_delayed_settings_backend_subscribe;
|
backend_class->subscribe = g_delayed_settings_backend_subscribe;
|
||||||
backend_class->unsubscribe = g_delayed_settings_backend_subscribe;
|
backend_class->unsubscribe = g_delayed_settings_backend_unsubscribe;
|
||||||
|
|
||||||
object_class->finalize = g_delayed_settings_backend_finalize;
|
object_class->finalize = g_delayed_settings_backend_finalize;
|
||||||
}
|
}
|
||||||
|
@@ -114,8 +114,7 @@ struct _GSettingsPrivate
|
|||||||
gchar *context;
|
gchar *context;
|
||||||
gchar *path;
|
gchar *path;
|
||||||
|
|
||||||
guint unapplied_handler;
|
GDelayedSettingsBackend *delayed;
|
||||||
gboolean delayed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -242,6 +241,7 @@ settings_backend_writable_changed (GSettingsBackend *backend,
|
|||||||
const gchar *string;
|
const gchar *string;
|
||||||
GQuark quark;
|
GQuark quark;
|
||||||
|
|
||||||
|
quark = g_quark_from_string (key + i);
|
||||||
string = g_quark_to_string (quark);
|
string = g_quark_to_string (quark);
|
||||||
|
|
||||||
quark = g_quark_from_string (key + i);
|
quark = g_quark_from_string (key + i);
|
||||||
@@ -358,12 +358,6 @@ g_settings_init (GSettings *settings)
|
|||||||
GSettingsPrivate);
|
GSettingsPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
g_settings_notify_unapplied (GSettings *settings)
|
|
||||||
{
|
|
||||||
g_object_notify (G_OBJECT (settings), "has-unapplied");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_settings_set_delay_apply:
|
* g_settings_set_delay_apply:
|
||||||
* @settings: a #GSettings object
|
* @settings: a #GSettings object
|
||||||
@@ -396,21 +390,6 @@ g_settings_delay (GSettings *settings)
|
|||||||
settings);
|
settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* g_settings_get_delay_apply:
|
|
||||||
* @settings: a #GSettings object
|
|
||||||
* @returns: %TRUE if changes in @settings are not applied immediately
|
|
||||||
*
|
|
||||||
* Returns whether the #GSettings object is in 'delay-apply' mode.
|
|
||||||
*
|
|
||||||
* Since: 2.26
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
g_settings_get_delay_apply (GSettings *settings)
|
|
||||||
{
|
|
||||||
return settings->priv->delayed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_settings_apply:
|
* g_settings_apply:
|
||||||
* @settings: a #GSettings instance
|
* @settings: a #GSettings instance
|
||||||
|
@@ -36,6 +36,7 @@ test_basic (void)
|
|||||||
str = NULL;
|
str = NULL;
|
||||||
|
|
||||||
g_settings_set (settings, "greeting", "s", "this is the end");
|
g_settings_set (settings, "greeting", "s", "this is the end");
|
||||||
|
g_object_unref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -205,6 +206,7 @@ test_basic_types (void)
|
|||||||
|
|
||||||
g_settings_get (settings, "test-objectpath", "o", &str);
|
g_settings_get (settings, "test-objectpath", "o", &str);
|
||||||
g_assert_cmpstr (str, ==, "/a/object/path");
|
g_assert_cmpstr (str, ==, "/a/object/path");
|
||||||
|
g_object_unref (settings);
|
||||||
g_free (str);
|
g_free (str);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
}
|
}
|
||||||
@@ -250,6 +252,8 @@ test_complex_types (void)
|
|||||||
g_assert_cmpint (i1, ==, 5);
|
g_assert_cmpint (i1, ==, 5);
|
||||||
g_assert (!g_variant_iter_next (iter, "i", &i1));
|
g_assert (!g_variant_iter_next (iter, "i", &i1));
|
||||||
g_variant_iter_free (iter);
|
g_variant_iter_free (iter);
|
||||||
|
|
||||||
|
g_object_unref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean changed_cb_called;
|
static gboolean changed_cb_called;
|
||||||
@@ -287,6 +291,8 @@ test_changes (void)
|
|||||||
g_settings_set (settings2, "greeting", "s", "hi");
|
g_settings_set (settings2, "greeting", "s", "hi");
|
||||||
g_assert (changed_cb_called);
|
g_assert (changed_cb_called);
|
||||||
|
|
||||||
|
g_object_unref (settings2);
|
||||||
|
g_object_unref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean changed_cb_called2;
|
static gboolean changed_cb_called2;
|
||||||
@@ -362,6 +368,9 @@ test_delay_apply (void)
|
|||||||
|
|
||||||
g_assert (!g_settings_get_has_unapplied (settings));
|
g_assert (!g_settings_get_has_unapplied (settings));
|
||||||
g_assert (!g_settings_get_has_unapplied (settings2));
|
g_assert (!g_settings_get_has_unapplied (settings2));
|
||||||
|
|
||||||
|
g_object_unref (settings2);
|
||||||
|
g_object_unref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -401,6 +410,9 @@ test_delay_revert (void)
|
|||||||
g_assert_cmpstr (str, ==, "top o' the morning");
|
g_assert_cmpstr (str, ==, "top o' the morning");
|
||||||
g_free (str);
|
g_free (str);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
|
|
||||||
|
g_object_unref (settings2);
|
||||||
|
g_object_unref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -472,6 +484,9 @@ test_atomic (void)
|
|||||||
g_assert_cmpstr (str, ==, "atomic bye-bye");
|
g_assert_cmpstr (str, ==, "atomic bye-bye");
|
||||||
g_free (str);
|
g_free (str);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
|
|
||||||
|
g_object_unref (settings2);
|
||||||
|
g_object_unref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -522,6 +537,7 @@ test_l10n (void)
|
|||||||
setlocale (LC_MESSAGES, locale);
|
setlocale (LC_MESSAGES, locale);
|
||||||
|
|
||||||
g_assert_cmpstr (str, ==, "Unbenannt");
|
g_assert_cmpstr (str, ==, "Unbenannt");
|
||||||
|
g_object_unref (settings);
|
||||||
g_free (str);
|
g_free (str);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user