WIP fix for #516, needs memory cleanup

This commit is contained in:
James Booth
2015-06-29 23:48:41 +01:00
parent fed55b5459
commit dd206ef637
13 changed files with 72 additions and 87 deletions

View File

@@ -922,14 +922,14 @@ win_show_status_string(ProfWin *window, const char * const from,
}
void
win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
const char * const from, const char * const message)
{
switch (window->type)
{
case WIN_CHAT:
case WIN_PRIVATE:
win_print(window, '-', tv_stamp, NO_ME, THEME_TEXT_THEM, from, message);
win_print(window, '-', timestamp, NO_ME, THEME_TEXT_THEM, from, message);
break;
default:
assert(FALSE);
@@ -938,31 +938,25 @@ win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
}
void
win_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp,
win_vprint(ProfWin *window, const char show_char, GDateTime *timestamp,
int flags, theme_item_t theme_item, const char * const from, const char * const message, ...)
{
va_list arg;
va_start(arg, message);
GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, message, arg);
win_print(window, show_char, tstamp, flags, theme_item, from, fmt_msg->str);
win_print(window, show_char, timestamp, flags, theme_item, from, fmt_msg->str);
g_string_free(fmt_msg, TRUE);
}
void
win_print(ProfWin *window, const char show_char, GTimeVal *tstamp,
win_print(ProfWin *window, const char show_char, GDateTime *timestamp,
int flags, theme_item_t theme_item, const char * const from, const char * const message)
{
GDateTime *time;
if (timestamp == NULL) timestamp = g_date_time_new_now_local();
if (tstamp == NULL) {
time = g_date_time_new_now_local();
} else {
time = g_date_time_new_from_timeval_utc(tstamp);
}
buffer_push(window->layout->buffer, show_char, time, flags, theme_item, from, message, NULL);
_win_print(window, show_char, time, flags, theme_item, from, message, NULL);
buffer_push(window->layout->buffer, show_char, timestamp, flags, theme_item, from, message, NULL);
_win_print(window, show_char, timestamp, flags, theme_item, from, message, NULL);
// TODO: cross-reference.. this should be replaced by a real event-based system
ui_input_nonblocking(TRUE);
}