diff options
author | James Booth <boothj5@gmail.com> | 2013-08-25 23:27:42 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-08-25 23:27:42 +0100 |
commit | d3cfeb9d5cac0520d43dbf35e36d9364c35a95e5 (patch) | |
tree | e262e193eadbb95717e6b04612ace879c7be5848 /src/ui/statusbar.c | |
parent | 3c39befa5e565bbc3cc13a0f060a8d7a18f735f1 (diff) | |
parent | e21bf8a18d682ae95699b6ddedf17aa870303a3c (diff) | |
download | profani-tty-d3cfeb9d5cac0520d43dbf35e36d9364c35a95e5.tar.gz |
Merge branch 'master' into windows
Diffstat (limited to 'src/ui/statusbar.c')
-rw-r--r-- | src/ui/statusbar.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 3f0798d3..6e7eae30 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -22,6 +22,7 @@ #include "config.h" +#include <assert.h> #include <string.h> #include <stdlib.h> @@ -63,6 +64,8 @@ create_status_bar(void) mvwprintw(status_bar, 0, cols - 31, _active); wattroff(status_bar, COLOUR_STATUS_BRACKET); + if (last_time != NULL) + g_date_time_unref(last_time); last_time = g_date_time_new_now_local(); dirty = TRUE; @@ -76,6 +79,8 @@ status_bar_refresh(void) if (elapsed >= 60000000) { dirty = TRUE; + if (last_time != NULL) + g_date_time_unref(last_time); last_time = g_date_time_new_now_local(); } @@ -113,6 +118,8 @@ status_bar_resize(void) if (message != NULL) mvwprintw(status_bar, 0, 10, message); + if (last_time != NULL) + g_date_time_unref(last_time); last_time = g_date_time_new_now_local(); dirty = TRUE; } @@ -184,14 +191,12 @@ status_bar_get_password(void) void status_bar_print_message(const char * const msg) { + werase(status_bar); + if (message != NULL) { free(message); - message = NULL; } - - werase(status_bar); - - message = (char *) malloc((strlen(msg) + 1) * sizeof(char)); + message = (char *) malloc(strlen(msg) + 1); strcpy(message, msg); mvwprintw(status_bar, 0, 10, message); @@ -270,6 +275,7 @@ static void _status_bar_update_time(void) { gchar *date_fmt = g_date_time_format(last_time, "%H:%M"); + assert(date_fmt != NULL); wattron(status_bar, COLOUR_STATUS_BRACKET); mvwaddch(status_bar, 0, 1, '['); @@ -279,7 +285,7 @@ _status_bar_update_time(void) mvwaddch(status_bar, 0, 7, ']'); wattroff(status_bar, COLOUR_STATUS_BRACKET); - free(date_fmt); + g_free(date_fmt); dirty = TRUE; } |