From d0c853034f220f662e9bdabea43a178117c3ecf9 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Fri, 8 Apr 2011 02:56:06 +0000 Subject: [PATCH] * Throw internal error if ncurses 'newwin' fails. * Cleaned up logging of mincore stats. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1203 e378c898-3ddf-0310-93e7-cc216c733640 --- doc/log_stats.plot | 2 +- src/display/canvas.cc | 7 +++++++ src/display/canvas.h | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/log_stats.plot b/doc/log_stats.plot index 9f10f735..f3d416a0 100644 --- a/doc/log_stats.plot +++ b/doc/log_stats.plot @@ -11,7 +11,7 @@ gnuplot << EOF # $throttle.unchoked_downloads= # $pieces.memory.current= # -# schedule = log_stats,5,10,"execute={log_rtorrent.sh,\"$cat=/foo/bar.,$system.pid=\",$system.time_seconds=,$throttle.global_up.rate=,$throttle.global_up.total=,$throttle.global_down.rate=,$throttle.global_down.total=,$throttle.unchoked_uploads=,$throttle.unchoked_downloads=,$pieces.memory.current=}" +# schedule = log_stats,5,10,((execute,log_rtorrent.sh,((cat,/foo/bandwidth_stats.,((system.pid)))),((system.time_seconds)),((throttle.global_up.rate)),((throttle.global_up.total)),((throttle.global_down.rate)),((throttle.global_down.total)),((throttle.unchoked_uploads)),((throttle.unchoked_downloads)),((pieces.memory.current)))) set terminal png diff --git a/src/display/canvas.cc b/src/display/canvas.cc index 4e621dfe..970d060e 100644 --- a/src/display/canvas.cc +++ b/src/display/canvas.cc @@ -47,6 +47,13 @@ namespace display { bool Canvas::m_isInitialized = false; +Canvas::Canvas(int x, int y, int width, int height) : + m_window(newwin(height, width, y, x)) { + + if (m_window == NULL) + throw torrent::internal_error("Could not allocate ncurses canvas."); +} + void Canvas::resize(int x, int y, int w, int h) { wresize(m_window, h, w); diff --git a/src/display/canvas.h b/src/display/canvas.h index 3f3ec286..ab57d6e2 100644 --- a/src/display/canvas.h +++ b/src/display/canvas.h @@ -48,8 +48,7 @@ class Canvas { public: typedef std::vector attributes_list; - Canvas(int x = 0, int y = 0, int width = 0, int height = 0) : - m_window(newwin(height, width, y, x)) {} + Canvas(int x = 0, int y = 0, int width = 0, int height = 0); ~Canvas() { delwin(m_window); } void refresh() { wnoutrefresh(m_window); }