diff --git a/src/event/server_events.c b/src/event/server_events.c index 7168828a..3e054fa9 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -548,7 +548,10 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c // handle self nick change if (muc_nick_change_pending(room)) { muc_nick_change_complete(room, nick); - mucwin_nick_change(room, nick); + ProfMucWin *mucwin = wins_get_muc(room); + if (mucwin) { + mucwin_nick_change(mucwin, nick); + } // handle roster complete } else if (!muc_roster_complete(room)) { diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 9288293e..f300abec 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -323,14 +323,12 @@ mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, cons } void -mucwin_nick_change(const char *const roomjid, const char *const nick) +mucwin_nick_change(ProfMucWin *mucwin, const char *const nick) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - if (window == NULL) { - log_error("Received self nick change %s, but no window open for %s.", nick, roomjid); - } else { - win_vprint(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick); - } + assert(mucwin != NULL); + + ProfWin *window = (ProfWin*)mucwin; + win_vprint(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 80073843..df5233bc 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -192,7 +192,7 @@ void mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick); void mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *const roles, const char *const affiliation, const char *const show, const char *const status); void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, const char *const nick); -void mucwin_nick_change(const char *const roomjid, const char *const nick); +void mucwin_nick_change(ProfMucWin *mucwin, const char *const nick); void mucwin_occupant_presence(ProfMucWin *mucwin, const char *const nick, const char *const show, const char *const status); void mucwin_update_occupants(const char *const roomjid); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index eec4af29..655b2ed8 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -231,7 +231,7 @@ void mucwin_occupant_offline(ProfMucWin *mucwin, const char * const nick) {} void mucwin_occupant_online(ProfMucWin *mucwin, const char * const nick, const char * const roles, const char * const affiliation, const char * const show, const char * const status) {} void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char * const old_nick, const char * const nick) {} -void mucwin_nick_change(const char * const roomjid, const char * const nick) {} +void mucwin_nick_change(ProfMucWin *mucwin, const char * const nick) {} void mucwin_occupant_presence(ProfMucWin *mucwin, const char * const nick, const char * const show, const char * const status) {} void mucwin_update_occupants(const char * const roomjid) {}