[gnome-builder] application: Fix leaking plugin settings
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] application: Fix leaking plugin settings
- Date: Tue, 1 Mar 2016 21:15:51 +0000 (UTC)
commit d736309f0184f8a4fbeb6bc5bd70e48d73d2c2be
Author: Patrick Griffis <tingping tingping se>
Date: Tue Mar 1 14:01:45 2016 -0500
application: Fix leaking plugin settings
libide/ide-application-plugins.c | 24 ++++++++++++++++++------
libide/ide-application-private.h | 2 ++
libide/ide-application.c | 1 +
3 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/libide/ide-application-plugins.c b/libide/ide-application-plugins.c
index 733a87d..1e7ae06 100644
--- a/libide/ide-application-plugins.c
+++ b/libide/ide-application-plugins.c
@@ -166,13 +166,25 @@ ide_application_plugins_enabled_changed (IdeApplication *self,
}
static GSettings *
-_ide_application_plugin_get_settings (const gchar *module_name)
+_ide_application_plugin_get_settings (IdeApplication *self,
+ const gchar *module_name)
{
- g_autofree gchar *path = NULL;
GSettings *settings;
- path = g_strdup_printf ("/org/gnome/builder/plugins/%s/", module_name);
- settings = g_settings_new_with_path ("org.gnome.builder.plugin", path);
+ if (G_UNLIKELY(self->plugin_settings == NULL))
+ {
+ self->plugin_settings = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_object_unref);
+ }
+
+ if (!(settings = g_hash_table_lookup (self->plugin_settings, module_name)))
+ {
+ g_autofree gchar *path = NULL;
+
+ path = g_strdup_printf ("/org/gnome/builder/plugins/%s/", module_name);
+ settings = g_settings_new_with_path ("org.gnome.builder.plugin", path);
+ g_hash_table_insert (self->plugin_settings, g_strdup (module_name), settings);
+ }
return settings;
}
@@ -195,7 +207,7 @@ ide_application_load_plugins (IdeApplication *self)
const gchar *module_name;
module_name = peas_plugin_info_get_module_name (plugin_info);
- settings = _ide_application_plugin_get_settings (module_name);
+ settings = _ide_application_plugin_get_settings (self, module_name);
g_object_set_data (G_OBJECT (settings), "PEAS_PLUGIN_INFO", plugin_info);
@@ -426,7 +438,7 @@ ide_application_init_plugin_menus (IdeApplication *self)
GSettings *settings;
module_name = peas_plugin_info_get_module_name (plugin_info);
- settings = _ide_application_plugin_get_settings (module_name);
+ settings = _ide_application_plugin_get_settings (self, module_name);
if (!g_settings_get_boolean (settings, "enabled"))
continue;
diff --git a/libide/ide-application-private.h b/libide/ide-application-private.h
index 3a78064..0d6aeaa 100644
--- a/libide/ide-application-private.h
+++ b/libide/ide-application-private.h
@@ -61,6 +61,8 @@ struct _IdeApplication
GHashTable *plugin_css;
GList *test_funcs;
+
+ GHashTable *plugin_settings;
};
void ide_application_discover_plugins (IdeApplication *self) G_GNUC_INTERNAL;
diff --git a/libide/ide-application.c b/libide/ide-application.c
index dfb5414..884f4c3 100644
--- a/libide/ide-application.c
+++ b/libide/ide-application.c
@@ -364,6 +364,7 @@ ide_application_finalize (GObject *object)
g_clear_pointer (&self->started_at, g_date_time_unref);
g_clear_pointer (&self->merge_ids, g_hash_table_unref);
g_clear_pointer (&self->plugin_css, g_hash_table_unref);
+ g_clear_pointer (&self->plugin_settings, g_hash_table_unref);
g_clear_object (&self->worker_manager);
g_clear_object (&self->keybindings);
g_clear_object (&self->recent_projects);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]