[geany/geany-plugins] c92f78: git-changebar: Fix repository monitoring after closing a file

Colomban Wendling git-noreply at xxxxx
Thu Mar 5 21:51:40 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Thu, 05 Mar 2015 21:51:40 UTC
Commit:      c92f785f13d9c74b482dffa43d5d7ccfb3efcd1c
             https://github.com/geany/geany-plugins/commit/c92f785f13d9c74b482dffa43d5d7ccfb3efcd1c

Log Message:
-----------
git-changebar: Fix repository monitoring after closing a file

The monitoring callbacks used to only push an update to the very
document for which the monitoring was initially setup.  However, as
monitoring is not reset when switching to another file in the same
repository, it was easy to nullify the monitoring by opening two files
from the same repository and closing the first one, as then the
monitoring callbacks couldn't push the update to the closed document.

So, fix the monitoring callbacks to push an update to the current
document at the moment they are fired.  This is not a problem because
the monitoring is properly reset when switching between different
repositories' files, and the update doesn't enforce a repository
anyway.


Modified Paths:
--------------
    git-changebar/src/gcb-plugin.c

Modified: git-changebar/src/gcb-plugin.c
47 lines changed, 13 insertions(+), 34 deletions(-)
===================================================================
@@ -112,16 +112,11 @@ struct GotoNextHunkData {
 };
 
 
-static void         on_git_head_changed         (GFileMonitor     *monitor,
+static void         on_git_repo_changed         (GFileMonitor     *monitor,
                                                  GFile            *file,
                                                  GFile            *other_file,
                                                  GFileMonitorEvent event_type,
-                                                 gpointer          user_data);
-static void         on_git_ref_changed          (GFileMonitor     *monitor,
-                                                 GFile            *file,
-                                                 GFile            *other_file,
-                                                 GFileMonitorEvent event_type,
-                                                 gpointer          user_data);
+                                                 gpointer          force);
 static gboolean     on_sci_query_tooltip        (GtkWidget   *widget,
                                                  gint         x,
                                                  gint         y,
@@ -327,11 +322,11 @@ worker_thread (gpointer data)
         /* we need to monitor HEAD, in case of e.g. branch switch (e.g.
          * git checkout -b will switch the ref we need to watch) */
         monitors[0] = monitor_repo_file (repo, "HEAD",
-                                         G_CALLBACK (on_git_head_changed),
-                                         job->user_data);
+                                         G_CALLBACK (on_git_repo_changed),
+                                         GINT_TO_POINTER (TRUE));
         /* and of course the real ref (branch) for when changes get committed */
-        monitors[1] = monitor_head_ref (repo, G_CALLBACK (on_git_ref_changed),
-                                        job->user_data);
+        monitors[1] = monitor_head_ref (repo, G_CALLBACK (on_git_repo_changed),
+                                        GINT_TO_POINTER (FALSE));
       }
     }
     
@@ -359,7 +354,6 @@ worker_thread (gpointer data)
   return NULL;
 }
 
-/* @user_data will also be used to the file monitor callback */
 static void
 get_cached_blob_async (const gchar   *path,
                        gboolean       force,
@@ -872,32 +866,17 @@ on_startup_complete (GObject *obj,
 }
 
 static void
-on_git_head_changed (GFileMonitor      *monitor,
-                     GFile             *file,
-                     GFile             *other_file,
-                     GFileMonitorEvent  event_type,
-                     gpointer           user_data)
+on_git_repo_changed (GFileMonitor     *monitor,
+                     GFile            *file,
+                     GFile            *other_file,
+                     GFileMonitorEvent event_type,
+                     gpointer          force)
 {
-  GeanyDocument *doc = document_find_by_id (GPOINTER_TO_UINT (user_data));
-  
-  if (doc) {
-    clear_cached_blob ();
-    update_diff_push (doc, TRUE);
-  }
-}
-
-static void
-on_git_ref_changed (GFileMonitor      *monitor,
-                    GFile             *file,
-                    GFile             *other_file,
-                    GFileMonitorEvent  event_type,
-                    gpointer           user_data)
-{
-  GeanyDocument *doc = document_find_by_id (GPOINTER_TO_UINT (user_data));
+  GeanyDocument *doc = document_get_current ();
   
   if (doc) {
     clear_cached_blob ();
-    update_diff_push (doc, FALSE);
+    update_diff_push (doc, GPOINTER_TO_INT (force));
   }
 }
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list