Commit 4d7440bf authored by Cedric Roux's avatar Cedric Roux

add more locks in view/textlist.c

no deadlock should be possible as of the current state of
things. When the textlist's lock is set the GUI lock is
never on.

Let's cross fingers that things don't change crazily in
the future...
parent 0d0756c0
...@@ -45,7 +45,6 @@ static void *textlist_thread(void *_this) ...@@ -45,7 +45,6 @@ static void *textlist_thread(void *_this)
_append(this, s, &deleted); _append(this, s, &deleted);
free(s); free(s);
} }
if (pthread_mutex_unlock(&this->lock)) abort();
if (dirty) { if (dirty) {
text_list_state(this->g, this->w, &visible_lines, &start_line, text_list_state(this->g, this->w, &visible_lines, &start_line,
&number_of_lines); &number_of_lines);
...@@ -58,6 +57,7 @@ static void *textlist_thread(void *_this) ...@@ -58,6 +57,7 @@ static void *textlist_thread(void *_this)
/* this call is not necessary, but if things change in text_list... */ /* this call is not necessary, but if things change in text_list... */
widget_dirty(this->g, this->w); widget_dirty(this->g, this->w);
} }
if (pthread_mutex_unlock(&this->lock)) abort();
sleepms(1000/this->refresh_rate); sleepms(1000/this->refresh_rate);
} }
...@@ -90,6 +90,8 @@ static void scroll(void *private, gui *g, ...@@ -90,6 +90,8 @@ static void scroll(void *private, gui *g,
int new_line; int new_line;
int inc; int inc;
if (pthread_mutex_lock(&this->lock)) abort();
text_list_state(g, w, &visible_lines, &start_line, &number_of_lines); text_list_state(g, w, &visible_lines, &start_line, &number_of_lines);
inc = 10; inc = 10;
if (inc > visible_lines - 2) inc = visible_lines - 2; if (inc > visible_lines - 2) inc = visible_lines - 2;
...@@ -107,6 +109,8 @@ static void scroll(void *private, gui *g, ...@@ -107,6 +109,8 @@ static void scroll(void *private, gui *g,
this->autoscroll = 0; this->autoscroll = 0;
else else
this->autoscroll = 1; this->autoscroll = 1;
if (pthread_mutex_unlock(&this->lock)) abort();
} }
static void click(void *private, gui *g, static void click(void *private, gui *g,
...@@ -116,7 +120,11 @@ static void click(void *private, gui *g, ...@@ -116,7 +120,11 @@ static void click(void *private, gui *g,
int *d = notification_data; int *d = notification_data;
int button = d[1]; int button = d[1];
if (pthread_mutex_lock(&this->lock)) abort();
if (button == 1) this->autoscroll = 1 - this->autoscroll; if (button == 1) this->autoscroll = 1 - this->autoscroll;
if (pthread_mutex_unlock(&this->lock)) abort();
} }
view *new_textlist(int maxsize, float refresh_rate, gui *g, widget *w) view *new_textlist(int maxsize, float refresh_rate, gui *g, widget *w)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment