From 1941bdcd645aa065cfcf0b78655b1949cd8a8a77 Mon Sep 17 00:00:00 2001 From: "emdee@spm.plastiras.org" Date: Tue, 30 Apr 2024 08:51:38 +0000 Subject: [PATCH] src/twc-profile.c --- src/twc-profile.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) 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); } } }