summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-06 17:08:40 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-06 17:08:40 +0100
commit200019574d66c1a04d25e23eb0a0fcda7c25f445 (patch)
treebe51843ce076412a5fdce1bd1e93b7482adb225d /src/windows.py
parentb9c6f08a790358c990462287bed2062257c5ba7a (diff)
downloadpoezio-200019574d66c1a04d25e23eb0a0fcda7c25f445.tar.gz
poezio-200019574d66c1a04d25e23eb0a0fcda7c25f445.tar.bz2
poezio-200019574d66c1a04d25e23eb0a0fcda7c25f445.tar.xz
poezio-200019574d66c1a04d25e23eb0a0fcda7c25f445.zip
Use threads RLock to avoid crash on simultaneous refresh and resize.
fixes #2180
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/windows.py b/src/windows.py
index 42c9bfa0..790dd858 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -24,7 +24,7 @@ import curses
import string
from config import config
-from threading import Lock
+from threading import RLock
from contact import Contact, Resource
from roster import RosterGroup, roster
@@ -46,7 +46,7 @@ allowed_color_digits = ('0', '1', '2', '3', '4', '5', '6', '7')
# first is a bool telling if this is the first line of the message.
Line = collections.namedtuple('Line', 'msg start_pos end_pos')
-g_lock = Lock()
+g_lock = RLock()
LINES_NB_LIMIT = 4096
@@ -79,7 +79,8 @@ class Win(object):
"""
Override if something has to be done on resize
"""
- self._resize(height, width, y, x)
+ with g_lock:
+ self._resize(height, width, y, x)
def _refresh(self):
self._win.noutrefresh()
@@ -255,10 +256,11 @@ class UserList(Win):
self._refresh()
def resize(self, height, width, y, x):
- self._resize(height, width, y, x)
- self._win.attron(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR))
- self._win.vline(0, 0, curses.ACS_VLINE, self.height)
- self._win.attroff(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR))
+ with g_lock:
+ self._resize(height, width, y, x)
+ self._win.attron(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR))
+ self._win.vline(0, 0, curses.ACS_VLINE, self.height)
+ self._win.attroff(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR))
class Topic(Win):
def __init__(self):
@@ -674,9 +676,10 @@ class TextWin(Win):
self.addstr(' ')
def resize(self, height, width, y, x, room=None):
- self._resize(height, width, y, x)
- if room:
- self.rebuild_everything(room)
+ with g_lock:
+ self._resize(height, width, y, x)
+ if room:
+ self.rebuild_everything(room)
def rebuild_everything(self, room):
self.built_lines = []