Commit 4d7440bf authored by Cédric Roux's avatar Cédric Roux
Browse files

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)
_append(this, s, &deleted);
free(s);
}
if (pthread_mutex_unlock(&this->lock)) abort();
if (dirty) {
text_list_state(this->g, this->w, &visible_lines, &start_line,
&number_of_lines);
......@@ -58,6 +57,7 @@ static void *textlist_thread(void *_this)
/* this call is not necessary, but if things change in text_list... */
widget_dirty(this->g, this->w);
}
if (pthread_mutex_unlock(&this->lock)) abort();
sleepms(1000/this->refresh_rate);
}
......@@ -90,6 +90,8 @@ static void scroll(void *private, gui *g,
int new_line;
int inc;
if (pthread_mutex_lock(&this->lock)) abort();
text_list_state(g, w, &visible_lines, &start_line, &number_of_lines);
inc = 10;
if (inc > visible_lines - 2) inc = visible_lines - 2;
......@@ -107,6 +109,8 @@ static void scroll(void *private, gui *g,
this->autoscroll = 0;
else
this->autoscroll = 1;
if (pthread_mutex_unlock(&this->lock)) abort();
}
static void click(void *private, gui *g,
......@@ -116,7 +120,11 @@ static void click(void *private, gui *g,
int *d = notification_data;
int button = d[1];
if (pthread_mutex_lock(&this->lock)) abort();
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)
......
Supports Markdown
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