diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-08-19 21:43:11 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-08-19 21:43:11 +0000 |
commit | dd1d7585f641b7319f59e9356286fd75df03fa70 (patch) | |
tree | ab7c96704495ef36c2fb3d2994304c2717322380 /src | |
parent | f179cbdd2e76f5b9ddc19ca737199f873a0d5719 (diff) | |
download | poezio-dd1d7585f641b7319f59e9356286fd75df03fa70.tar.gz poezio-dd1d7585f641b7319f59e9356286fd75df03fa70.tar.bz2 poezio-dd1d7585f641b7319f59e9356286fd75df03fa70.tar.xz poezio-dd1d7585f641b7319f59e9356286fd75df03fa70.zip |
A tentative to fix the 'glitch' bug due to both thread writing on the screen
Diffstat (limited to 'src')
-rw-r--r-- | src/window.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/window.py b/src/window.py index 7ba09b6c..6aa44899 100644 --- a/src/window.py +++ b/src/window.py @@ -26,8 +26,12 @@ locale.setlocale(locale.LC_ALL, '') import curses from config import config +from threading import Lock + from message import Line +g_lock = Lock() + class Win(object): def __init__(self, height, width, y, x, parent_win): self._resize(height, width, y, x, parent_win) @@ -84,6 +88,7 @@ class UserList(Win): return arole - brole if not self.visible: return + g_lock.acquire() self.win.erase() y = 0 for user in sorted(users, compare_user): @@ -108,6 +113,7 @@ class UserList(Win): if y == self.height: break self.win.refresh() + g_lock.release() def resize(self, height, width, y, x, stdscr, visible): self.visible = visible @@ -126,6 +132,7 @@ class Topic(Win): def refresh(self, topic, jid=None): if not self.visible: return + g_lock.acquire() self.win.erase() if not jid: try: @@ -145,6 +152,7 @@ class Topic(Win): , curses.color_pair(15)) self.win.refresh() + g_lock.release() class RoomInfo(Win): def __init__(self, height, width, y, x, parent_win, visible): @@ -168,6 +176,7 @@ class RoomInfo(Win): return def compare_room(a, b): return a.nb - b.nb + g_lock.acquire() self.win.erase() self.win.addnstr(0, 0, "[", self.width ,curses.color_pair(1)) @@ -195,6 +204,7 @@ class RoomInfo(Win): except: break self.win.refresh() + g_lock.release() class TextWin(Win): """ @@ -275,6 +285,7 @@ class TextWin(Win): """ if not self.visible: return + g_lock.acquire() self.win.erase() lines = self.build_lines_from_messages(room.messages) if room.pos + self.height > len(lines): @@ -299,6 +310,7 @@ class TextWin(Win): self.write_text(y, line.text_offset, line.text, line.text_color) y += 1 self.win.refresh() + g_lock.release() def write_line_separator(self): """ @@ -465,7 +477,6 @@ class Input(Win): """ if not len(self.history): return - self.reset_completion() self.win.erase() if self.histo_pos >= 0: self.histo_pos -= 1 |