Code

End the current update before begining a new one; fixes CPU hogging
authorJonas Fonseca <fonseca@diku.dk>
Sun, 21 May 2006 23:04:49 +0000 (01:04 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Sun, 21 May 2006 23:04:49 +0000 (01:04 +0200)
tig.c

diff --git a/tig.c b/tig.c
index bf5309254db1ac46aa89a25e4db7a545fbed16cb..236c701935d1689ad2278c65820999fee65b1844 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1075,11 +1075,27 @@ move_view(struct view *view, enum request request, bool redraw)
  * Incremental updating
  */
 
+static void
+end_update(struct view *view)
+{
+       if (!view->pipe)
+               return;
+       set_nonblocking_input(FALSE);
+       if (view->pipe == stdin)
+               fclose(view->pipe);
+       else
+               pclose(view->pipe);
+       view->pipe = NULL;
+}
+
 static bool
 begin_update(struct view *view)
 {
        const char *id = view->id;
 
+       if (view->pipe)
+               end_update(view);
+
        if (opt_cmd[0]) {
                string_copy(view->cmd, opt_cmd);
                opt_cmd[0] = 0;
@@ -1128,19 +1144,6 @@ begin_update(struct view *view)
        return TRUE;
 }
 
-static void
-end_update(struct view *view)
-{
-       if (!view->pipe)
-               return;
-       set_nonblocking_input(FALSE);
-       if (view->pipe == stdin)
-               fclose(view->pipe);
-       else
-               pclose(view->pipe);
-       view->pipe = NULL;
-}
-
 static bool
 update_view(struct view *view)
 {