[epiphany] Revert "Use only two GKeyfileSettingsBackends per process"
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Revert "Use only two GKeyfileSettingsBackends per process"
- Date: Thu, 7 Nov 2019 22:40:25 +0000 (UTC)
commit 031ff75ccee82848e29f2db7e0d6d78d0ebc6e3b
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Thu Nov 7 16:40:14 2019 -0600
Revert "Use only two GKeyfileSettingsBackends per process"
This reverts commit 1b3a1b16913341647291569d58b4508885517f62.
Broken.
lib/ephy-permissions-manager.c | 20 ++++++++------------
lib/ephy-settings.c | 17 +++++++----------
2 files changed, 15 insertions(+), 22 deletions(-)
---
diff --git a/lib/ephy-permissions-manager.c b/lib/ephy-permissions-manager.c
index 030a08390..bd7e88dcb 100644
--- a/lib/ephy-permissions-manager.c
+++ b/lib/ephy-permissions-manager.c
@@ -39,8 +39,6 @@ struct _EphyPermissionsManager {
GHashTable *permission_type_permitted_origins;
GHashTable *permission_type_denied_origins;
-
- GSettingsBackend *backend;
};
G_DEFINE_TYPE (EphyPermissionsManager, ephy_permissions_manager, G_TYPE_OBJECT)
@@ -50,8 +48,6 @@ G_DEFINE_TYPE (EphyPermissionsManager, ephy_permissions_manager, G_TYPE_OBJECT)
static void
ephy_permissions_manager_init (EphyPermissionsManager *manager)
{
- g_autofree char *filename = NULL;
-
manager->origins_mapping = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
manager->settings_mapping = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
@@ -59,11 +55,6 @@ ephy_permissions_manager_init (EphyPermissionsManager *manager)
* the GList keys without destroying the contents of the lists. */
manager->permission_type_permitted_origins = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
NULL);
manager->permission_type_denied_origins = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
NULL);
-
- /* The GKeyfileBackend needs to be shared to avoid overconsumption of inotify
- * handles. See: epiphany #865. */
- filename = g_build_filename (ephy_profile_dir (), PERMISSIONS_FILENAME, NULL);
- manager->backend = g_keyfile_settings_backend_new (filename, "/", NULL);
}
static void
@@ -94,8 +85,6 @@ ephy_permissions_manager_dispose (GObject *object)
manager->permission_type_denied_origins = NULL;
}
- g_clear_object (&manager->backend);
-
G_OBJECT_CLASS (ephy_permissions_manager_parent_class)->dispose (object);
}
@@ -113,6 +102,8 @@ ephy_permissions_manager_get_settings_for_origin (EphyPermissionsManager *manage
{
char *origin_path;
char *trimmed_protocol;
+ char *filename;
+ GSettingsBackend *backend;
GSettings *settings;
WebKitSecurityOrigin *security_origin;
char *pos;
@@ -123,6 +114,10 @@ ephy_permissions_manager_get_settings_for_origin (EphyPermissionsManager *manage
if (settings)
return settings;
+ filename = g_build_filename (ephy_profile_dir (), PERMISSIONS_FILENAME, NULL);
+ backend = g_keyfile_settings_backend_new (filename, "/", NULL);
+ g_free (filename);
+
/* Cannot contain consecutive slashes in GSettings path... */
security_origin = webkit_security_origin_new_for_uri (origin);
trimmed_protocol = g_strdup (webkit_security_origin_get_protocol (security_origin));
@@ -135,9 +130,10 @@ ephy_permissions_manager_get_settings_for_origin (EphyPermissionsManager *manage
webkit_security_origin_get_host (security_origin),
webkit_security_origin_get_port (security_origin));
- settings = g_settings_new_with_backend_and_path ("org.gnome.Epiphany.permissions", manager->backend,
origin_path);
+ settings = g_settings_new_with_backend_and_path ("org.gnome.Epiphany.permissions", backend, origin_path);
g_free (trimmed_protocol);
g_free (origin_path);
+ g_object_unref (backend);
webkit_security_origin_unref (security_origin);
/* Note that settings is owned only by the first hash table! */
diff --git a/lib/ephy-settings.c b/lib/ephy-settings.c
index b2b568c8d..2d29b5618 100644
--- a/lib/ephy-settings.c
+++ b/lib/ephy-settings.c
@@ -204,7 +204,7 @@ ephy_settings_get_for_web_process_extension (const char *schema)
gsettings = g_hash_table_lookup (settings, key_name);
if (gsettings == NULL) {
- static GSettingsBackend *backend = NULL;
+ g_autoptr (GSettingsBackend) backend = NULL;
g_autoptr (GSettings) web_gsettings = NULL;
g_autofree char *keyfile_path = NULL;
g_autofree char *path = NULL;
@@ -212,20 +212,17 @@ ephy_settings_get_for_web_process_extension (const char *schema)
gsettings = ephy_settings_get (schema);
g_assert (gsettings != NULL);
- /* GLib inside Flatpak already defaults to this backend. */
+ /* GLib inside Flatpak will default to this backend in the future */
+ /* so we don't need to do anything extra */
g_object_get (gsettings, "backend", &backend, NULL);
- if (g_strcmp0 (g_type_name (G_TYPE_FROM_INSTANCE (backend)), "GKeyfileSettingsBackend") == 0) {
+ /* G_IS_KEYFILE_SETTINGS_BACKEND () is private API */
+ if (!g_strcmp0 (g_type_name (G_TYPE_FROM_INSTANCE (backend)), "GKeyfileSettingsBackend")) {
g_hash_table_insert (settings, g_steal_pointer (&key_name), g_object_ref (gsettings));
return gsettings;
}
- if (!backend) {
- /* The GKeyfileBackend needs to be shared to avoid overconsumption of
- * inotify handles. See: epiphany #865.
- */
- keyfile_path = g_build_filename (ephy_config_dir (), "web-extension-settings.ini", NULL);
- backend = g_keyfile_settings_backend_new (keyfile_path, "/", "/");
- }
+ keyfile_path = g_build_filename (ephy_config_dir (), "web-extension-settings.ini", NULL);
+ backend = g_keyfile_settings_backend_new (keyfile_path, "/", "/");
path = get_relocatable_path (schema);
if (path != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]