diff --git a/src/twc-profile.c b/src/twc-profile.c index c01356f..8f40d73 100644 --- a/src/twc-profile.c +++ b/src/twc-profile.c @@ -575,26 +575,34 @@ twc_profile_set_online_status(struct t_twc_profile *profile, bool status) if (!(profile)) { weechat_printf(profile->buffer, "%sno profile", weechat_prefix("network")); - } else if (profile->tox_online ^ status) { - TOX_CONNECTION connection = tox_self_get_connection_status(profile->tox); + return; + } + /* failsafe - called while exiting! */ + if (!(profile->tox)) { + weechat_printf(profile->buffer, "%sno tox", + weechat_prefix("network")); + return; + } + if (profile->tox_online ^ status) { + TOX_CONNECTION connection = tox_self_get_connection_status(profile->tox); - profile->tox_online = status; - twc_profile_refresh_online_status(); + profile->tox_online = status; + twc_profile_refresh_online_status(); - if (connection == TOX_CONNECTION_TCP) + if (connection == TOX_CONNECTION_TCP) { - weechat_printf(profile->buffer, "%sprofile %s TCP", - weechat_prefix("network"), profile->name); + weechat_printf(profile->buffer, "%sprofile %s TCP", + weechat_prefix("network"), profile->name); } - else if (connection == TOX_CONNECTION_UDP) + else if (connection == TOX_CONNECTION_UDP) { - weechat_printf(profile->buffer, "%sprofile %s UDP", - weechat_prefix("network"), profile->name); + weechat_printf(profile->buffer, "%sprofile %s UDP", + weechat_prefix("network"), profile->name); } - else + else { - weechat_printf(profile->buffer, "%sprofile %s disconnected", - weechat_prefix("network"), profile->name); + weechat_printf(profile->buffer, "%sprofile %s disconnected", + weechat_prefix("network"), profile->name); } } }