"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: tog: todo item #2 respond to key presses while "loading..."
To:
Mark Jamsek <mark@jamsek.com>, Game of Trees <gameoftrees@openbsd.org>
Date:
Sat, 13 Aug 2022 11:53:27 +0200

Download raw body.

Thread
On Sat, Aug 13, 2022 at 11:39:17AM +0200, Stefan Sperling wrote:
> On Fri, Aug 12, 2022 at 11:36:46PM +0200, Stefan Sperling wrote:
> > Here is a case where movement doesn't seem to work while loading:
> > 
> > 	tog log path
> > 
> > Where path is any file in a deep history that has seen few changes.
> > The top-level Makefile in OpenBSD src.git is one such file.
> 
> This can be fixed by... well, simply not waiting for the log thread.
> 
> In hindsight, the articicial blocking behaviour was probably a bad idea.
> If we remove related code, the tog log view remains responsive at all times.
> 
> ok?

Hmm, with that change the crashes start showing up.

For starters, we need to be careful about pointers which will be NULL
before the thread has initialized them. We can fix this already before
actually removing any log wait code.

Ok?

I haven't found any other issues yet, but still testing.

diff 11edf34c28f6c60a1d37d5c83c758e90df02fe7a f3ce181c406d83111ef235eeb1ac6bcb962cf655
commit - 11edf34c28f6c60a1d37d5c83c758e90df02fe7a
commit + f3ce181c406d83111ef235eeb1ac6bcb962cf655
blob - fa53f96cb444650badb64394f0e1af4d9ea769f7
blob + 65fe22564e7665a2c9a872b7e1e868b9ed62f0ae
--- tog/tog.c
+++ tog/tog.c
@@ -3209,8 +3209,11 @@ log_move_cursor_down(struct tog_view *view, int page)
 	 * We might necessarily overshoot in horizontal
 	 * splits; if so, select the last displayed commit.
 	 */
-	s->selected = MIN(s->selected,
-	    s->last_displayed_entry->idx - s->first_displayed_entry->idx);
+	if (s->first_displayed_entry && s->last_displayed_entry) {
+		s->selected = MIN(s->selected,
+		    s->last_displayed_entry->idx -
+		    s->first_displayed_entry->idx);
+	}
 
 	select_commit(s);
 
@@ -3268,6 +3271,9 @@ log_goto_line(struct tog_view *view, int nlines)
 	struct tog_log_view_state	*s = &view->state.log;
 	int				 g, idx = s->selected_entry->idx;
 
+	if (s->first_displayed_entry == NULL || s->last_displayed_entry == NULL)
+		return NULL;
+
 	g = view->gline;
 	view->gline = 0;