From 817179a7606b616795cf67e24505526dded34381 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Mon, 13 Aug 2018 14:43:25 +0200 Subject: [PATCH] Revert "Flag topic as unset if it is zero length" --- .gitignore | 1 - src/irc/core/channel-events.c | 22 ++++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 1ab7df5f..916457f8 100644 --- a/.gitignore +++ b/.gitignore @@ -59,7 +59,6 @@ tests/irc/core/test-irc.trs *.la *.lo *.o -*.swp *~ *.tar.bz2 diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 4b74b322..46bbd5fa 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -126,25 +126,23 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, chanrec = channel_find(SERVER(server), channel); if (chanrec == NULL) return; - - g_free_and_null(chanrec->topic); - g_free_and_null(chanrec->topic_by); - chanrec->topic_time = 0; - - /* the topic may be sent out encoded, so we need to + /* the topic may be send out encoded, so we need to recode it back or /topic will not work properly */ recoded = recode_in(SERVER(server), topic, channel); - if (recoded == NULL || *recoded == '\0') { - signal_emit("channel topic changed", 1, chanrec); - g_free(recoded); - return; + if (topic != NULL) { + g_free_not_null(chanrec->topic); + chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded); } + g_free(recoded); - chanrec->topic = recoded; + g_free_not_null(chanrec->topic_by); chanrec->topic_by = g_strdup(setby); - if (chanrec->topic_by != NULL) { + + if (chanrec->topic_by == NULL) { /* ensure invariant topic_time > 0 <=> topic_by != NULL. this could be triggered by a topic command without sender */ + chanrec->topic_time = 0; + } else { chanrec->topic_time = settime; }