[gnome-builder] editor: don't share GSettings instances
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: don't share GSettings instances
- Date: Wed, 19 Jul 2017 11:04:40 +0000 (UTC)
commit f1c340195487210bda7cadf7ae6a0c7ca1963bc8
Author: Christian Hergert <chergert redhat com>
Date: Sat Jul 1 14:07:43 2017 -0700
editor: don't share GSettings instances
These should be per-editor as the docs don't explicitly state
that sharing them is okay.
libide/editor/ide-editor-private.h | 3 ++
libide/editor/ide-editor-view-settings.c | 48 +++++++++++++----------------
libide/editor/ide-editor-view.c | 10 ++++--
3 files changed, 32 insertions(+), 29 deletions(-)
---
diff --git a/libide/editor/ide-editor-private.h b/libide/editor/ide-editor-private.h
index 1f61388..b47da46 100644
--- a/libide/editor/ide-editor-private.h
+++ b/libide/editor/ide-editor-private.h
@@ -33,6 +33,9 @@ struct _IdeEditorView
IdeExtensionSetAdapter *addins;
+ GSettings *editor_settings;
+ GSettings *insight_settings;
+
IdeBuffer *buffer;
DzlBindingGroup *buffer_bindings;
DzlSignalGroup *buffer_signals;
diff --git a/libide/editor/ide-editor-view-settings.c b/libide/editor/ide-editor-view-settings.c
index 45eb227..5d0d4ba 100644
--- a/libide/editor/ide-editor-view-settings.c
+++ b/libide/editor/ide-editor-view-settings.c
@@ -20,9 +20,6 @@
#include "ide-editor-private.h"
-static GSettings *editor_settings;
-static GSettings *insight_settings;
-
static gboolean
get_smart_home_end (GValue *value,
GVariant *variant,
@@ -73,84 +70,83 @@ _ide_editor_view_init_settings (IdeEditorView *self)
IdeBuffer *buffer;
g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (!editor_settings || G_IS_SETTINGS (editor_settings));
-
- if (editor_settings == NULL)
- editor_settings = g_settings_new ("org.gnome.builder.editor");
+ g_assert (self->editor_settings == NULL);
+ g_assert (self->insight_settings == NULL);
source_view = ide_editor_view_get_view (self);
buffer = ide_editor_view_get_buffer (self);
- g_settings_bind (editor_settings, "highlight-current-line",
+ self->editor_settings = g_settings_new ("org.gnome.builder.editor");
+
+ g_settings_bind (self->editor_settings, "highlight-current-line",
source_view, "highlight-current-line",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "highlight-matching-brackets",
+ g_settings_bind (self->editor_settings, "highlight-matching-brackets",
buffer, "highlight-matching-brackets",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "show-line-changes",
+ g_settings_bind (self->editor_settings, "show-line-changes",
source_view, "show-line-changes",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "show-line-numbers",
+ g_settings_bind (self->editor_settings, "show-line-numbers",
source_view, "show-line-numbers",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "smart-backspace",
+ g_settings_bind (self->editor_settings, "smart-backspace",
source_view, "smart-backspace",
G_SETTINGS_BIND_GET);
- g_settings_bind_with_mapping (editor_settings, "smart-home-end",
+ g_settings_bind_with_mapping (self->editor_settings, "smart-home-end",
source_view, "smart-home-end",
G_SETTINGS_BIND_GET,
get_smart_home_end, NULL, NULL, NULL);
- g_settings_bind (editor_settings, "style-scheme-name",
+ g_settings_bind (self->editor_settings, "style-scheme-name",
buffer, "style-scheme-name",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "font-name",
+ g_settings_bind (self->editor_settings, "font-name",
source_view, "font-name",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "overscroll",
+ g_settings_bind (self->editor_settings, "overscroll",
source_view, "overscroll",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "scroll-offset",
+ g_settings_bind (self->editor_settings, "scroll-offset",
source_view, "scroll-offset",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "show-grid-lines",
+ g_settings_bind (self->editor_settings, "show-grid-lines",
source_view, "show-grid-lines",
G_SETTINGS_BIND_GET);
- g_settings_bind_with_mapping (editor_settings, "wrap-text",
+ g_settings_bind_with_mapping (self->editor_settings, "wrap-text",
source_view, "wrap-mode",
G_SETTINGS_BIND_GET,
get_wrap_mode, NULL, NULL, NULL);
- g_settings_bind (editor_settings, "show-map",
+ g_settings_bind (self->editor_settings, "show-map",
self, "show-map",
G_SETTINGS_BIND_GET);
- g_settings_bind (editor_settings, "auto-hide-map",
+ g_settings_bind (self->editor_settings, "auto-hide-map",
self, "auto-hide-map",
G_SETTINGS_BIND_GET);
- g_signal_connect_object (editor_settings,
+ g_signal_connect_object (self->editor_settings,
"changed::keybindings",
G_CALLBACK (on_keybindings_changed),
self,
G_CONNECT_SWAPPED);
- on_keybindings_changed (self, "keybindings", editor_settings);
+ on_keybindings_changed (self, "keybindings", self->editor_settings);
- if (insight_settings == NULL)
- insight_settings = g_settings_new ("org.gnome.builder.code-insight");
+ self->insight_settings = g_settings_new ("org.gnome.builder.code-insight");
- g_settings_bind (insight_settings, "word-completion",
+ g_settings_bind (self->insight_settings, "word-completion",
source_view, "enable-word-completion",
G_SETTINGS_BIND_GET);
}
diff --git a/libide/editor/ide-editor-view.c b/libide/editor/ide-editor-view.c
index 770bd3e..dfabc15 100644
--- a/libide/editor/ide-editor-view.c
+++ b/libide/editor/ide-editor-view.c
@@ -414,8 +414,15 @@ ide_editor_view_destroy (GtkWidget *widget)
g_assert (IDE_IS_EDITOR_VIEW (self));
+ ide_clear_source (&self->toggle_map_source);
+
g_clear_object (&self->addins);
+ g_clear_object (&self->editor_settings);
+ g_clear_object (&self->insight_settings);
+
+ g_clear_object (&self->buffer);
+
if (self->buffer_bindings != NULL)
{
dzl_binding_group_set_source (self->buffer_bindings, NULL);
@@ -428,9 +435,6 @@ ide_editor_view_destroy (GtkWidget *widget)
g_clear_object (&self->buffer_signals);
}
- g_clear_object (&self->buffer);
- ide_clear_source (&self->toggle_map_source);
-
GTK_WIDGET_CLASS (ide_editor_view_parent_class)->destroy (widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]