[gnome-builder/wip/libide] libide: force reload of git object when git vcs is reloaded



commit 48f19472cc0347825e75902e94c9f78b3c22364a
Author: Christian Hergert <christian hergert me>
Date:   Thu Feb 26 21:05:58 2015 -0800

    libide: force reload of git object when git vcs is reloaded

 libide/git/ide-git-buffer-change-monitor.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/libide/git/ide-git-buffer-change-monitor.c b/libide/git/ide-git-buffer-change-monitor.c
index 700fbe0..59ee75b 100644
--- a/libide/git/ide-git-buffer-change-monitor.c
+++ b/libide/git/ide-git-buffer-change-monitor.c
@@ -20,8 +20,10 @@
 #include <libgit2-glib/ggit.h>
 
 #include "ide-buffer.h"
+#include "ide-context.h"
 #include "ide-file.h"
 #include "ide-git-buffer-change-monitor.h"
+#include "ide-git-vcs.h"
 
 /**
  * SECTION:ide-git-buffer-change-monitor
@@ -385,10 +387,23 @@ ide_git_buffer_change_monitor__buffer_changed_after_cb (IdeGitBufferChangeMonito
 }
 
 static void
+ide_git_buffer_change_monitor__vcs_reloaded_cb (IdeGitBufferChangeMonitor *self,
+                                                IdeGitVcs                 *vcs)
+{
+  g_assert (IDE_IS_GIT_BUFFER_CHANGE_MONITOR (self));
+  g_assert (IDE_IS_GIT_VCS (vcs));
+
+  /* force reload of the git object on next calculation */
+  g_clear_object (&self->cached_blob);
+}
+
+static void
 ide_git_buffer_change_monitor_set_buffer (IdeBufferChangeMonitor *monitor,
                                           IdeBuffer              *buffer)
 {
   IdeGitBufferChangeMonitor *self = (IdeGitBufferChangeMonitor *)monitor;
+  IdeContext *context;
+  IdeVcs *vcs;
 
   g_return_if_fail (IDE_IS_GIT_BUFFER_CHANGE_MONITOR (self));
   g_return_if_fail (IDE_IS_BUFFER (buffer));
@@ -396,6 +411,9 @@ ide_git_buffer_change_monitor_set_buffer (IdeBufferChangeMonitor *monitor,
 
   self->buffer = g_object_ref (buffer);
 
+  context = ide_object_get_context (IDE_OBJECT (self));
+  vcs = ide_context_get_vcs (context);
+
   g_signal_connect_object (self->buffer,
                            "insert-text",
                            G_CALLBACK (ide_git_buffer_change_monitor__buffer_insert_text_after_cb),
@@ -419,6 +437,12 @@ ide_git_buffer_change_monitor_set_buffer (IdeBufferChangeMonitor *monitor,
                            G_CALLBACK (ide_git_buffer_change_monitor__buffer_changed_after_cb),
                            self,
                            G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+
+  g_signal_connect_object (vcs,
+                           "reloaded",
+                           G_CALLBACK (ide_git_buffer_change_monitor__vcs_reloaded_cb),
+                           self,
+                           G_CONNECT_SWAPPED);
 }
 
 static gint


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