Acquire lock before updating the CursesLogHandler window

Make sure that we refresh the screen atomically, since the emit()
function may be called by more that one threads at a time.

Also, modify the draw_bannerwin() method which used to fail in case the
window would become too small. Make sure that the provided offsets to
the window.addstr() method are properly bounded.

Closes #160: blinkenlights display is broken
Tested-by: Cyril Brulebois
Tested-by: Gaudenz Steinlin
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Ilias Tsitsimpis 2017-04-12 13:25:46 +03:00 committed by Nicolas Sebrecht
parent 2b1c842a7d
commit 7bc54d241c

View File

@ -315,11 +315,11 @@ class CursesLogHandler(logging.StreamHandler):
y,x = self.ui.logwin.getyx()
if y or x: self.ui.logwin.addch(10) # no \n before 1st item
self.ui.logwin.addstr(log_str, color)
self.ui.logwin.noutrefresh()
self.ui.stdscr.refresh()
finally:
self.ui.unlock()
self.ui.tframe_lock.release()
self.ui.logwin.noutrefresh()
self.ui.stdscr.refresh()
class Blinkenlights(UIBase, CursesUtil):
"""Curses-cased fancy UI.
@ -613,9 +613,10 @@ class Blinkenlights(UIBase, CursesUtil):
self.bannerwin.bkgd(' ', color) # Fill background with that color
string = "%s %s" % (offlineimap.__productname__,
offlineimap.__version__)
self.bannerwin.addstr(0, 0, string, color)
self.bannerwin.addstr(0, self.width -len(offlineimap.__copyright__) -1,
offlineimap.__copyright__, color)
spaces = " " * max(1, (self.width - len(offlineimap.__copyright__)
- len(string) - 1))
string = "%s%s%s" % (string, spaces, offlineimap.__copyright__)
self.bannerwin.addnstr(0, 0, string, self.width - 1, color)
self.bannerwin.noutrefresh()
def draw_logwin(self):