[gnome-builder] app: clear cached projects-directory when gsetting changes



commit 05dffb5a072873b62264fb333cd2878d7ce488a2
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jan 26 16:18:13 2018 -0800

    app: clear cached projects-directory when gsetting changes
    
    When our projects-directory GSetting changes, we need to drop our cached
    copy (it will get updated on next request).
    
    Fixes #341

 src/libide/application/ide-application.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/src/libide/application/ide-application.c b/src/libide/application/ide-application.c
index bde467ac0..cf94bcf02 100644
--- a/src/libide/application/ide-application.c
+++ b/src/libide/application/ide-application.c
@@ -470,6 +470,18 @@ _ide_application_reap_legacy (IdeApplication *self)
   IDE_EXIT;
 }
 
+static void
+projects_directory_changed_cb (IdeApplication *self,
+                               const gchar    *key,
+                               GSettings      *settings)
+{
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (IDE_IS_APPLICATION (self));
+  g_assert (G_IS_SETTINGS (settings));
+
+  g_clear_object (&self->projects_directory);
+}
+
 static void
 ide_application_startup (GApplication *application)
 {
@@ -480,6 +492,12 @@ ide_application_startup (GApplication *application)
 
   self->settings = g_settings_new ("org.gnome.builder");
 
+  g_signal_connect_object (self->settings,
+                           "changed::projects-directory",
+                           G_CALLBACK (projects_directory_changed_cb),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   g_resources_register (ide_get_resource ());
   g_resources_register (ide_icons_get_resource ());
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]