Merge pull request #1208 from ailin-nemui/daychange

do not use localtime result after other functions
This commit is contained in:
ailin-nemui 2020-07-16 12:07:16 +02:00 committed by GitHub
commit 40ed4122b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -679,10 +679,11 @@ static void sig_server_disconnected(SERVER_REC *server)
} }
} }
static void window_print_daychange(WINDOW_REC *window, struct tm *tm) static void window_print_daychange(WINDOW_REC *window, time_t t)
{ {
THEME_REC *theme; THEME_REC *theme;
TEXT_DEST_REC dest; TEXT_DEST_REC dest;
struct tm *tm;
char *format, str[256]; char *format, str[256];
int ret; int ret;
@ -690,6 +691,7 @@ static void window_print_daychange(WINDOW_REC *window, struct tm *tm)
format_create_dest(&dest, NULL, NULL, MSGLEVEL_NEVER, window); format_create_dest(&dest, NULL, NULL, MSGLEVEL_NEVER, window);
format = format_get_text_theme(theme, MODULE_NAME, &dest, format = format_get_text_theme(theme, MODULE_NAME, &dest,
TXT_DAYCHANGE); TXT_DAYCHANGE);
tm = localtime(&t);
ret = strftime(str, sizeof(str), format, tm); ret = strftime(str, sizeof(str), format, tm);
g_free(format); g_free(format);
if (ret <= 0) return; if (ret <= 0) return;
@ -770,7 +772,7 @@ static void sig_print_text(void)
/* day changed, print notice about it to every window */ /* day changed, print notice about it to every window */
for (tmp = windows; tmp != NULL; tmp = tmp->next) for (tmp = windows; tmp != NULL; tmp = tmp->next)
window_print_daychange(tmp->data, tm); window_print_daychange(tmp->data, t);
} }
static int sig_check_daychange(void) static int sig_check_daychange(void)