Code

Fix the view notification of end of reading
authorJonas Fonseca <fonseca@diku.dk>
Sun, 27 Apr 2008 22:21:07 +0000 (00:21 +0200)
committerJonas Fonseca <fonseca@diku.dk>
Sun, 27 Apr 2008 22:33:20 +0000 (00:33 +0200)
Move notification from update_view() to end_update() so <view>_read()
functions are also called when the user requests that loading views
are stopped. Allow ends to be forced so the extra spawning in the
blame view is closed as well.

tig.c

diff --git a/tig.c b/tig.c
index 2a0d793c0bc338aed2f1bc8a6eb50d31e2da3af0..14fbf35a9f834eef1d392848a314944a37a3516c 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2163,10 +2163,13 @@ search_view(struct view *view, enum request request)
  */
 
 static void
-end_update(struct view *view)
+end_update(struct view *view, bool force)
 {
        if (!view->pipe)
                return;
+       while (!view->ops->read(view, NULL))
+               if (!force)
+                       return;
        set_nonblocking_input(FALSE);
        if (view->pipe == stdin)
                fclose(view->pipe);
@@ -2179,7 +2182,7 @@ static bool
 begin_update(struct view *view)
 {
        if (view->pipe)
-               end_update(view);
+               end_update(view, TRUE);
 
        if (opt_cmd[0]) {
                string_copy(view->cmd, opt_cmd);
@@ -2384,21 +2387,18 @@ update_view(struct view *view)
 check_pipe:
        if (ferror(view->pipe)) {
                report("Failed to read: %s", strerror(errno));
-               goto end;
+               end_update(view, TRUE);
 
        } else if (feof(view->pipe)) {
                report("");
-               goto end;
+               end_update(view, FALSE);
        }
 
        return TRUE;
 
 alloc_error:
        report("Allocation failure");
-
-end:
-       if (view->ops->read(view, NULL))
-               end_update(view);
+       end_update(view, TRUE);
        return FALSE;
 }
 
@@ -2815,7 +2815,7 @@ view_driver(struct view *view, enum request request)
                        view = &views[i];
                        if (view->pipe)
                                report("Stopped loading the %s view", view->name),
-                       end_update(view);
+                       end_update(view, TRUE);
                }
                break;