diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2023-03-21 01:59:19 -0500 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2023-03-21 01:59:19 -0500 |
commit | 2084fe5e81b4aeef4b1c73ad1aaad8f8909f28c4 (patch) | |
tree | 61d0d58720b804e2b7441bceab594f48b6475235 | |
parent | 33e30d196909b08f359f5465a9ee4fab7a632a45 (diff) | |
download | pidgin-2084fe5e81b4aeef4b1c73ad1aaad8f8909f28c4.tar.gz |
Use g_clear_handle_id everywhere
Testing Done:
Compiled and ran tests in valgrind.
Reviewed at https://reviews.imfreedom.org/r/2374/
30 files changed, 73 insertions, 209 deletions
diff --git a/finch/gntblist.c b/finch/gntblist.c index d21e7846bb..bb35924609 100644 --- a/finch/gntblist.c +++ b/finch/gntblist.c @@ -306,9 +306,7 @@ static GList *managers; static void finch_blist_node_free(FinchBlistNode *node) { - if(node->signed_timer) { - g_source_remove(node->signed_timer); - } + g_clear_handle_id(&node->signed_timer, g_source_remove); g_free(node); } @@ -741,8 +739,7 @@ add_group_cb(FinchBuddyList *ggblist, const char *group) * make things easier to add buddies to empty groups (new or old) without having * to turn on 'show empty groups' setting */ ggblist->new_group = g_list_prepend(ggblist->new_group, grp); - if (ggblist->new_group_timeout) - g_source_remove(ggblist->new_group_timeout); + g_clear_handle_id(&ggblist->new_group_timeout, g_source_remove); ggblist->new_group_timeout = g_timeout_add_seconds(SHOW_EMPTY_GROUP_TIMEOUT, remove_new_empty_group, NULL); @@ -1841,13 +1838,11 @@ reset_blist_window(G_GNUC_UNUSED GntWidget *window, { purple_signals_disconnect_by_handle(finch_blist_get_handle()); - if (ggblist->typing) - g_source_remove(ggblist->typing); + g_clear_handle_id(&ggblist->typing, g_source_remove); remove_peripherals(ggblist); g_clear_list(&ggblist->tagged, NULL); - if (ggblist->new_group_timeout) - g_source_remove(ggblist->new_group_timeout); + g_clear_handle_id(&ggblist->new_group_timeout, g_source_remove); g_clear_list(&ggblist->new_group, NULL); ggblist = NULL; @@ -2070,9 +2065,7 @@ remove_typing_cb(G_GNUC_UNUSED gpointer data) gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree); end: g_free(escnewmessage); - if (ggblist->typing) - g_source_remove(ggblist->typing); - ggblist->typing = 0; + g_clear_handle_id(&ggblist->typing, g_source_remove); return FALSE; } @@ -2119,9 +2112,7 @@ status_text_changed(G_GNUC_UNUSED GntEntry *entry, const char *text, if ((text[0] == 27 || (text[0] == '\t' && text[1] == '\0')) && ggblist->typing == 0) return FALSE; - if (ggblist->typing) - g_source_remove(ggblist->typing); - ggblist->typing = 0; + g_clear_handle_id(&ggblist->typing, g_source_remove); if (text[0] == '\r' && text[1] == 0) { @@ -2340,8 +2331,7 @@ buddy_recent_signed_on_off(gpointer data) PurpleBlistNode *node = data; FinchBlistNode *fnode = g_object_get_data(G_OBJECT(node), UI_DATA); - g_source_remove(fnode->signed_timer); - fnode->signed_timer = 0; + g_clear_handle_id(&fnode->signed_timer, g_source_remove); if (!ggblist->manager->can_add_node(node)) { node_remove(purple_blist_get_default(), node); @@ -2364,9 +2354,7 @@ buddy_signed_on_off_cb(gpointer data) return FALSE; } - if(fnode->signed_timer) { - g_source_remove(fnode->signed_timer); - } + g_clear_handle_id(&fnode->signed_timer, g_source_remove); g_object_ref(node); fnode->signed_timer = g_timeout_add_seconds(6, (GSourceFunc)buddy_recent_signed_on_off, data); diff --git a/finch/gntconn.c b/finch/gntconn.c index a521ed646e..82b07e9a10 100644 --- a/finch/gntconn.c +++ b/finch/gntconn.c @@ -50,8 +50,7 @@ free_auto_recon(gpointer data) { FinchAutoRecon *info = data; - if (info->timeout != 0) - g_source_remove(info->timeout); + g_clear_handle_id(&info->timeout, g_source_remove); g_free(info); } @@ -99,8 +98,7 @@ finch_connection_report_disconnect(PurpleConnection *gc, info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX); } else { info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); - if (info->timeout != 0) - g_source_remove(info->timeout); + g_clear_handle_id(&info->timeout, g_source_remove); } info->timeout = g_timeout_add_seconds(info->delay, do_signon, account); } else { diff --git a/libpurple/accounts.c b/libpurple/accounts.c index 4293e10545..0b064c9d95 100644 --- a/libpurple/accounts.c +++ b/libpurple/accounts.c @@ -679,10 +679,8 @@ void purple_accounts_uninit(void) { gpointer handle = purple_accounts_get_handle(); - if (save_timer != 0) - { - g_source_remove(save_timer); - save_timer = 0; + if(save_timer != 0) { + g_clear_handle_id(&save_timer, g_source_remove); sync_accounts(); } diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c index 81abd33acc..fb77bfb61c 100644 --- a/libpurple/buddylist.c +++ b/libpurple/buddylist.c @@ -2171,9 +2171,8 @@ purple_blist_uninit(void) if (purplebuddylist == NULL) return; - if (save_timer != 0) { - g_source_remove(save_timer); - save_timer = 0; + if(save_timer != 0) { + g_clear_handle_id(&save_timer, g_source_remove); purple_blist_sync(); } diff --git a/libpurple/connection.c b/libpurple/connection.c index 9511fcf443..8b6be13f03 100644 --- a/libpurple/connection.c +++ b/libpurple/connection.c @@ -837,10 +837,7 @@ purple_connection_dispose(GObject *obj) { g_clear_object(&priv->account); - if(priv->disconnect_timeout > 0) { - g_source_remove(priv->disconnect_timeout); - priv->disconnect_timeout = 0; - } + g_clear_handle_id(&priv->disconnect_timeout, g_source_remove); G_OBJECT_CLASS(purple_connection_parent_class)->dispose(obj); } diff --git a/libpurple/idle.c b/libpurple/idle.c index b999f2cdba..2168f52a7e 100644 --- a/libpurple/idle.c +++ b/libpurple/idle.c @@ -282,9 +282,7 @@ idle_reporting_cb(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED PurplePrefType type, G_GNUC_UNUSED gconstpointer val, G_GNUC_UNUSED gpointer data) { - if (idle_timer) - g_source_remove(idle_timer); - idle_timer = 0; + g_clear_handle_id(&idle_timer, g_source_remove); check_idleness_timer(NULL); } @@ -294,9 +292,7 @@ purple_idle_touch(void) time(&last_active_time); if (!no_away) { - if (idle_timer) - g_source_remove(idle_timer); - idle_timer = 0; + g_clear_handle_id(&idle_timer, g_source_remove); check_idleness_timer(NULL); } } @@ -373,9 +369,7 @@ purple_idle_uninit(void) purple_prefs_disconnect_by_handle(purple_idle_get_handle()); /* Remove the idle timer */ - if (idle_timer > 0) - g_source_remove(idle_timer); - idle_timer = 0; + g_clear_handle_id(&idle_timer, g_source_remove); g_clear_object(&idle_ui); } diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c index 1b5613cc2e..9c2e6ec471 100644 --- a/libpurple/mediamanager.c +++ b/libpurple/mediamanager.c @@ -479,15 +479,8 @@ free_appdata_info_locked (PurpleMediaAppDataInfo *info) info->readable_cb_token = 0; info->writable_cb_token = 0; - if (info->readable_timer_id) { - g_source_remove (info->readable_timer_id); - info->readable_timer_id = 0; - } - - if (info->writable_timer_id) { - g_source_remove (info->writable_timer_id); - info->writable_timer_id = 0; - } + g_clear_handle_id(&info->readable_timer_id, g_source_remove); + g_clear_handle_id(&info->writable_timer_id, g_source_remove); g_clear_pointer(&info->current_sample, gst_sample_unref); @@ -1582,15 +1575,8 @@ purple_media_manager_set_application_data_callbacks(PurpleMediaManager *manager, info->notify (info->user_data); } - if (info->readable_cb_token) { - g_source_remove (info->readable_timer_id); - info->readable_cb_token = 0; - } - - if (info->writable_cb_token) { - g_source_remove (info->writable_timer_id); - info->writable_cb_token = 0; - } + g_clear_handle_id(&info->readable_cb_token, g_source_remove); + g_clear_handle_id(&info->writable_cb_token, g_source_remove); if (callbacks) { info->callbacks = *callbacks; diff --git a/libpurple/prefs.c b/libpurple/prefs.c index 83e5d4d7c5..268cefc9b3 100644 --- a/libpurple/prefs.c +++ b/libpurple/prefs.c @@ -1478,9 +1478,8 @@ purple_prefs_init(void) void purple_prefs_uninit(void) { - if (save_timer != 0) - { - g_source_remove(save_timer); + if(save_timer != 0) { + g_clear_handle_id(&save_timer, g_source_remove); save_cb(NULL); } diff --git a/libpurple/protocols/bonjour/xmpp.c b/libpurple/protocols/bonjour/xmpp.c index 0f9ae2da00..883013286a 100644 --- a/libpurple/protocols/bonjour/xmpp.c +++ b/libpurple/protocols/bonjour/xmpp.c @@ -254,8 +254,7 @@ _send_data_write_cb(GObject *stream, gpointer data) writelen = purple_circular_buffer_get_max_read(bconv->tx_buf); if (writelen == 0) { - g_source_remove(bconv->tx_handler); - bconv->tx_handler = 0; + g_clear_handle_id(&bconv->tx_handler, g_source_remove); return; } @@ -525,8 +524,7 @@ _start_stream(GObject *stream, gpointer data) bconv->stream_data = NULL; /* Stream started; process the send buffer if there is one */ - g_source_remove(bconv->tx_handler); - bconv->tx_handler = 0; + g_clear_handle_id(&bconv->tx_handler, g_source_remove); bconv->sent_stream_start = FULLY_SENT; bonjour_xmpp_stream_started(bconv); @@ -1187,14 +1185,8 @@ bonjour_xmpp_close_conversation(BonjourXMPPConversation *bconv) G_INPUT_STREAM(bconv->input), G_OUTPUT_STREAM(bconv->output)); } - if (bconv->rx_handler != 0) { - g_source_remove(bconv->rx_handler); - bconv->rx_handler = 0; - } - if (bconv->tx_handler != 0) { - g_source_remove(bconv->tx_handler); - bconv->tx_handler = 0; - } + g_clear_handle_id(&bconv->rx_handler, g_source_remove); + g_clear_handle_id(&bconv->tx_handler, g_source_remove); /* Cancel any pending operations. */ if (bconv->cancellable != NULL) { @@ -1218,9 +1210,7 @@ bonjour_xmpp_close_conversation(BonjourXMPPConversation *bconv) bonjour_parser_setup(bconv); } - if (bconv->close_timeout != 0) { - g_source_remove(bconv->close_timeout); - } + g_clear_handle_id(&bconv->close_timeout, g_source_remove); g_free(bconv->buddy_name); g_free(bconv->ip); diff --git a/libpurple/protocols/facebook/data.c b/libpurple/protocols/facebook/data.c index 3f58c0803a..b9288162ad 100644 --- a/libpurple/protocols/facebook/data.c +++ b/libpurple/protocols/facebook/data.c @@ -292,8 +292,8 @@ fb_data_clear_timeout(FbData *fata, const gchar *name, gboolean remove) ptr = g_hash_table_lookup(fata->evs, name); id = GPOINTER_TO_UINT(ptr); - if ((id > 0) && remove) { - g_source_remove(id); + if(remove) { + g_clear_handle_id(&id, g_source_remove); } g_hash_table_remove(fata->evs, name); diff --git a/libpurple/protocols/facebook/mqtt.c b/libpurple/protocols/facebook/mqtt.c index adced88b1f..b666010b0e 100644 --- a/libpurple/protocols/facebook/mqtt.c +++ b/libpurple/protocols/facebook/mqtt.c @@ -217,10 +217,7 @@ fb_mqtt_close(FbMqtt *mqtt) { g_return_if_fail(FB_IS_MQTT(mqtt)); - if(mqtt->tev > 0) { - g_source_remove(mqtt->tev); - mqtt->tev = 0; - } + g_clear_handle_id(&mqtt->tev, g_source_remove); if(mqtt->cancellable != NULL) { g_cancellable_cancel(mqtt->cancellable); @@ -303,10 +300,7 @@ fb_mqtt_cb_timeout(gpointer data) static void fb_mqtt_timeout_clear(FbMqtt *mqtt) { - if(mqtt->tev > 0) { - g_source_remove(mqtt->tev); - mqtt->tev = 0; - } + g_clear_handle_id(&mqtt->tev, g_source_remove); } static void diff --git a/libpurple/protocols/gg/edisc.c b/libpurple/protocols/gg/edisc.c index c9f7fa61d1..03573c67c0 100644 --- a/libpurple/protocols/gg/edisc.c +++ b/libpurple/protocols/gg/edisc.c @@ -1467,10 +1467,7 @@ ggp_xfer_finalize(GObject *obj) { #endif g_clear_object(&edisc_xfer->msg); - if(edisc_xfer->handler) { - g_source_remove(edisc_xfer->handler); - edisc_xfer->handler = 0; - } + g_clear_handle_id(&edisc_xfer->handler, g_source_remove); if (edisc_xfer->ticket_id != NULL) { g_hash_table_remove(sdata->xfers_initialized, diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c index e183370b4d..34294eb6b9 100644 --- a/libpurple/protocols/gg/gg.c +++ b/libpurple/protocols/gg/gg.c @@ -516,8 +516,7 @@ ggp_async_login_handler(gpointer _gc, G_GNUC_UNUSED gint fd, purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", info->session->check, info->session->state); - g_source_remove(info->inpa); - info->inpa = 0; + g_clear_handle_id(&info->inpa, g_source_remove); /** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */ if (info->session->fd >= 0) @@ -550,10 +549,7 @@ ggp_async_login_handler(gpointer _gc, G_GNUC_UNUSED gint fd, } break; case GG_EVENT_CONN_FAILED: - if (info->inpa > 0) { - g_source_remove(info->inpa); - info->inpa = 0; - } + g_clear_handle_id(&info->inpa, g_source_remove); purple_debug_info("gg", "Connection failure: %d\n", ev->event.failure); switch (ev->event.failure) { @@ -909,8 +905,7 @@ ggp_close(G_GNUC_UNUSED PurpleProtocol *protocol, PurpleConnection *gc) { ggp_message_cleanup(gc); ggp_edisc_cleanup(gc); - if (info->inpa > 0) - g_source_remove(info->inpa); + g_clear_handle_id(&info->inpa, g_source_remove); g_free(info->imtoken); if (info->http) { diff --git a/libpurple/protocols/gg/roster.c b/libpurple/protocols/gg/roster.c index 1072f3f121..8a5c409ca1 100644 --- a/libpurple/protocols/gg/roster.c +++ b/libpurple/protocols/gg/roster.c @@ -239,8 +239,7 @@ void ggp_roster_cleanup(PurpleConnection *gc) { ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc); - if (rdata->timer) - g_source_remove(rdata->timer); + g_clear_handle_id(&rdata->timer, g_source_remove); ggp_roster_content_free(rdata->content); g_list_free_full(rdata->sent_updates, ggp_roster_change_free); g_list_free_full(rdata->pending_updates, ggp_roster_change_free); diff --git a/libpurple/protocols/gg/tcpsocket.c b/libpurple/protocols/gg/tcpsocket.c index 5f9fa71c6a..abfb4870db 100644 --- a/libpurple/protocols/gg/tcpsocket.c +++ b/libpurple/protocols/gg/tcpsocket.c @@ -115,10 +115,7 @@ ggp_tcpsocket_connected(GObject *source, GAsyncResult *res, gpointer user_data) info = purple_connection_get_protocol_data(data->gc); - if (info->inpa > 0) { - g_source_remove(info->inpa); - info->inpa = 0; - } + g_clear_handle_id(&info->inpa, g_source_remove); if (info->session->fd < 0) return; diff --git a/libpurple/protocols/irc/dcc_send.c b/libpurple/protocols/irc/dcc_send.c index f1354ff6ac..35fc61518c 100644 --- a/libpurple/protocols/irc/dcc_send.c +++ b/libpurple/protocols/irc/dcc_send.c @@ -173,8 +173,7 @@ irc_dccsend_send_read(gpointer data, int source, return; else if (len <= 0) { /* XXX: Shouldn't this be canceling the transfer? */ - g_source_remove(xd->inpa); - xd->inpa = 0; + g_clear_handle_id(&xd->inpa, g_source_remove); return; } @@ -203,8 +202,7 @@ irc_dccsend_send_read(gpointer data, int source, } if ((goffset)acked >= purple_xfer_get_size(xfer)) { - g_source_remove(xd->inpa); - xd->inpa = 0; + g_clear_handle_id(&xd->inpa, g_source_remove); purple_xfer_set_completed(xfer, TRUE); purple_xfer_end(xfer); return; @@ -387,9 +385,7 @@ irc_xfer_finalize(GObject *obj) { g_socket_service_stop(xfer->service); } g_clear_object(&xfer->service); - if(xfer->inpa > 0) { - g_source_remove(xfer->inpa); - } + g_clear_handle_id(&xfer->inpa, g_source_remove); g_clear_object(&xfer->conn); G_OBJECT_CLASS(irc_xfer_parent_class)->finalize(obj); diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c index a8d9f5d7bd..4304650b88 100644 --- a/libpurple/protocols/irc/irc.c +++ b/libpurple/protocols/irc/irc.c @@ -708,8 +708,7 @@ irc_close(G_GNUC_UNUSED PurpleProtocol *protocol, PurpleConnection *gc) { g_clear_object(&irc->output); g_clear_object(&irc->conn); - if (irc->timer) - g_source_remove(irc->timer); + g_clear_handle_id(&irc->timer, g_source_remove); g_hash_table_destroy(irc->cmds); g_hash_table_destroy(irc->msgs); g_hash_table_destroy(irc->buddies); diff --git a/libpurple/protocols/jabber/bosh.c b/libpurple/protocols/jabber/bosh.c index 6af10f05bc..121d939c7f 100644 --- a/libpurple/protocols/jabber/bosh.c +++ b/libpurple/protocols/jabber/bosh.c @@ -155,8 +155,7 @@ jabber_bosh_connection_destroy(PurpleJabberBOSHConnection *conn) jabber_bosh_connection_send_now(conn); } - if (conn->send_timer) - g_source_remove(conn->send_timer); + g_clear_handle_id(&conn->send_timer, g_source_remove); soup_session_abort(conn->payload_reqs); @@ -295,10 +294,7 @@ jabber_bosh_connection_send_now(PurpleJabberBOSHConnection *conn) g_return_if_fail(conn != NULL); - if (conn->send_timer != 0) { - g_source_remove(conn->send_timer); - conn->send_timer = 0; - } + g_clear_handle_id(&conn->send_timer, g_source_remove); if (conn->sid == NULL) return; diff --git a/libpurple/protocols/jabber/buddy.c b/libpurple/protocols/jabber/buddy.c index d04f97cae1..5abb850808 100644 --- a/libpurple/protocols/jabber/buddy.c +++ b/libpurple/protocols/jabber/buddy.c @@ -705,8 +705,7 @@ jabber_setup_set_info(G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, static void jabber_buddy_info_destroy(JabberBuddyInfo *jbi) { /* Remove the timeout, which would otherwise trigger jabber_buddy_get_info_timeout() */ - if (jbi->timeout_handle > 0) - g_source_remove(jbi->timeout_handle); + g_clear_handle_id(&jbi->timeout_handle, g_source_remove); g_slist_free(jbi->ids); g_free(jbi->jid); diff --git a/libpurple/protocols/jabber/caps.c b/libpurple/protocols/jabber/caps.c index 9bfc8f9c78..e1b57dcbd7 100644 --- a/libpurple/protocols/jabber/caps.c +++ b/libpurple/protocols/jabber/caps.c @@ -202,9 +202,8 @@ void jabber_caps_init(void) void jabber_caps_uninit(void) { - if (save_timer != 0) { - g_source_remove(save_timer); - save_timer = 0; + if(save_timer != 0) { + g_clear_handle_id(&save_timer, g_source_remove); do_jabber_caps_store(NULL); } g_clear_pointer(&capstable, g_hash_table_destroy); diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c index cf43c270ed..dd317f1bfe 100644 --- a/libpurple/protocols/jabber/jabber.c +++ b/libpurple/protocols/jabber/jabber.c @@ -701,8 +701,7 @@ static void tls_init(JabberStream *js) GIOStream *tls_conn; GError *error = NULL; - g_source_remove(js->inpa); - js->inpa = 0; + g_clear_handle_id(&js->inpa, g_source_remove); js->input = NULL; g_filter_output_stream_set_close_base_stream( G_FILTER_OUTPUT_STREAM(js->output), FALSE); @@ -1009,10 +1008,7 @@ jabber_close(G_GNUC_UNUSED PurpleProtocol *protocol, PurpleConnection *gc) { * * jabber_send_raw(js, "</stream:stream>", -1); */ - if(js->inpa) { - g_source_remove(js->inpa); - js->inpa = 0; - } + g_clear_handle_id(&js->inpa, g_source_remove); purple_gio_graceful_close(js->stream, js->input, G_OUTPUT_STREAM(js->output)); } @@ -1053,12 +1049,9 @@ jabber_close(G_GNUC_UNUSED PurpleProtocol *protocol, PurpleConnection *gc) { g_free(js->old_msg); g_free(js->old_avatarhash); - if (js->keepalive_timeout != 0) - g_source_remove(js->keepalive_timeout); - if (js->inactivity_timer != 0) - g_source_remove(js->inactivity_timer); - if (js->conn_close_timeout != 0) - g_source_remove(js->conn_close_timeout); + g_clear_handle_id(&js->keepalive_timeout, g_source_remove); + g_clear_handle_id(&js->inactivity_timer, g_source_remove); + g_clear_handle_id(&js->conn_close_timeout, g_source_remove); g_cancellable_cancel(js->cancellable); g_object_unref(G_OBJECT(js->cancellable)); @@ -1447,10 +1440,7 @@ inactivity_cb(gpointer data) void jabber_stream_restart_inactivity_timer(JabberStream *js) { - if (js->inactivity_timer != 0) { - g_source_remove(js->inactivity_timer); - js->inactivity_timer = 0; - } + g_clear_handle_id(&js->inactivity_timer, g_source_remove); g_return_if_fail(js->max_inactivity > 0); diff --git a/libpurple/protocols/jabber/ping.c b/libpurple/protocols/jabber/ping.c index 7d2adae23d..b861b4829f 100644 --- a/libpurple/protocols/jabber/ping.c +++ b/libpurple/protocols/jabber/ping.c @@ -35,10 +35,7 @@ jabber_keepalive_pong_cb(JabberStream *js, G_GNUC_UNUSED const char *from, G_GNUC_UNUSED PurpleXmlNode *packet, G_GNUC_UNUSED gpointer data) { - if (js->keepalive_timeout != 0) { - g_source_remove(js->keepalive_timeout); - js->keepalive_timeout = 0; - } + g_clear_handle_id(&js->keepalive_timeout, g_source_remove); } void diff --git a/libpurple/protocols/jabber/si.c b/libpurple/protocols/jabber/si.c index 602c46ba09..5746ed3ece 100644 --- a/libpurple/protocols/jabber/si.c +++ b/libpurple/protocols/jabber/si.c @@ -185,10 +185,7 @@ jabber_si_bytestreams_connect_cb(GObject *source, GAsyncResult *result, static void jabber_si_bytestreams_ibb_timeout_remove(JabberSIXfer *jsx) { - if (jsx->ibb_timeout_handle) { - g_source_remove(jsx->ibb_timeout_handle); - jsx->ibb_timeout_handle = 0; - } + g_clear_handle_id(&jsx->ibb_timeout_handle, g_source_remove); } static gboolean @@ -1847,13 +1844,8 @@ jabber_si_xfer_finalize(GObject *obj) { jabber_iq_remove_callback_by_id(js, jsx->iq_id); } - if (jsx->connect_timeout > 0) { - g_source_remove(jsx->connect_timeout); - } - - if (jsx->ibb_timeout_handle > 0) { - g_source_remove(jsx->ibb_timeout_handle); - } + g_clear_handle_id(&jsx->connect_timeout, g_source_remove); + g_clear_handle_id(&jsx->ibb_timeout_handle, g_source_remove); g_list_free_full(jsx->streamhosts, (GDestroyNotify)jabber_bytestreams_streamhost_free); diff --git a/libpurple/purpleconversationmember.c b/libpurple/purpleconversationmember.c index aad18474ff..771e13c647 100644 --- a/libpurple/purpleconversationmember.c +++ b/libpurple/purpleconversationmember.c @@ -128,10 +128,7 @@ purple_conversation_member_dispose(GObject *obj) { g_clear_object(&member->contact_info); - if(member->typing_timeout != 0) { - g_source_remove(member->typing_timeout); - member->typing_timeout = 0; - } + g_clear_handle_id(&member->typing_timeout, g_source_remove); G_OBJECT_CLASS(purple_conversation_member_parent_class)->dispose(obj); } @@ -246,10 +243,7 @@ purple_conversation_member_set_typing_state(PurpleConversationMember *member, g_return_if_fail(PURPLE_IS_CONVERSATION_MEMBER(member)); /* Remove an existing timeout if necessary. */ - if(member->typing_timeout != 0) { - g_source_remove(member->typing_timeout); - member->typing_timeout = 0; - } + g_clear_handle_id(&member->typing_timeout, g_source_remove); /* If the state has changed, notify. */ if(state != member->typing_state) { diff --git a/libpurple/purpleimconversation.c b/libpurple/purpleimconversation.c index 5ca7c0eb0e..8ac8b9bc8a 100644 --- a/libpurple/purpleimconversation.c +++ b/libpurple/purpleimconversation.c @@ -274,10 +274,7 @@ purple_im_conversation_start_typing_timeout(PurpleIMConversation *im, { g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im)); - if(im->typing_timeout > 0) { - purple_im_conversation_stop_typing_timeout(im); - } - + purple_im_conversation_stop_typing_timeout(im); im->typing_timeout = g_timeout_add_seconds(timeout, purple_im_conversation_reset_typing_cb, im); @@ -287,12 +284,7 @@ void purple_im_conversation_stop_typing_timeout(PurpleIMConversation *im) { g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im)); - if(im->typing_timeout == 0) { - return; - } - - g_source_remove(im->typing_timeout); - im->typing_timeout = 0; + g_clear_handle_id(&im->typing_timeout, g_source_remove); } guint @@ -334,12 +326,7 @@ void purple_im_conversation_stop_send_typed_timeout(PurpleIMConversation *im) { g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im)); - if(im->send_typed_timeout == 0) { - return; - } - - g_source_remove(im->send_typed_timeout); - im->send_typed_timeout = 0; + g_clear_handle_id(&im->typing_timeout, g_source_remove); } guint diff --git a/libpurple/savedstatuses.c b/libpurple/savedstatuses.c index 04c51b6a36..3b8b967c2a 100644 --- a/libpurple/savedstatuses.c +++ b/libpurple/savedstatuses.c @@ -1261,10 +1261,8 @@ purple_savedstatuses_uninit(void) remove_old_transient_statuses(); - if (save_timer != 0) - { - g_source_remove(save_timer); - save_timer = 0; + if(save_timer != 0) { + g_clear_handle_id(&save_timer, g_source_remove); sync_statuses(); } diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c index bd4ab55d25..4955ab96a1 100644 --- a/pidgin/gtkmedia.c +++ b/pidgin/gtkmedia.c @@ -388,9 +388,7 @@ pidgin_media_dispose(GObject *media) g_clear_object(>kmedia->priv->ui); - if (gtkmedia->priv->timeout_id != 0) { - g_source_remove(gtkmedia->priv->timeout_id); - } + g_clear_handle_id(>kmedia->priv->timeout_id, g_source_remove); g_clear_pointer(>kmedia->priv->recv_progressbars, g_hash_table_destroy); g_clear_pointer(>kmedia->priv->remote_videos, g_hash_table_destroy); @@ -768,8 +766,7 @@ pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia, const gchar *si } if (purple_media_is_initiator(media, sid, NULL) == FALSE) { - if (gtkmedia->priv->timeout_id != 0) - g_source_remove(gtkmedia->priv->timeout_id); + g_clear_handle_id(>kmedia->priv->timeout_id, g_source_remove); gtkmedia->priv->request_type |= type; gtkmedia->priv->timeout_id = g_timeout_add(500, (GSourceFunc)pidgin_request_timeout_cb, diff --git a/pidgin/gtkroomlist.c b/pidgin/gtkroomlist.c index cf48bcc315..4c1066bd25 100644 --- a/pidgin/gtkroomlist.c +++ b/pidgin/gtkroomlist.c @@ -80,9 +80,6 @@ pidgin_roomlist_close(PidginRoomlistDialog *dialog) if (dialog->roomlist && purple_roomlist_get_in_progress(dialog->roomlist)) purple_roomlist_cancel_get_list(dialog->roomlist); - if (dialog->pg_update_to > 0) - g_source_remove(dialog->pg_update_to); - if (dialog->roomlist) { PidginRoomlist *rl = NULL; @@ -98,6 +95,8 @@ pidgin_roomlist_close(PidginRoomlistDialog *dialog) g_object_unref(dialog->roomlist); } + g_clear_handle_id(&dialog->pg_update_to, g_source_remove); + dialog->progress = NULL; } diff --git a/pidgin/pidgindebug.c b/pidgin/pidgindebug.c index 67ff10cb15..08d662d8e5 100644 --- a/pidgin/pidgindebug.c +++ b/pidgin/pidgindebug.c @@ -925,14 +925,8 @@ pidgin_debug_init(void) void pidgin_debug_uninit(void) { - if(pref_callback_id != 0) { - purple_prefs_disconnect_callback(pref_callback_id); - } - pref_callback_id = 0; - if(debug_enabled_timer != 0) { - g_source_remove(debug_enabled_timer); - } - debug_enabled_timer = 0; + g_clear_handle_id(&pref_callback_id, purple_prefs_disconnect_callback); + g_clear_handle_id(&debug_enabled_timer, g_source_remove); } void * diff --git a/pidgin/plugins/gestures/stroke-draw.c b/pidgin/plugins/gestures/stroke-draw.c index 6aff3ad02a..81e859877a 100644 --- a/pidgin/plugins/gestures/stroke-draw.c +++ b/pidgin/plugins/gestures/stroke-draw.c @@ -96,10 +96,7 @@ gstroke_cancel(GtkWidget *widget, GdkEvent *event) { last_mouse_position.invalid = TRUE; - if (timer_id > 0) - g_source_remove (timer_id); - - timer_id = 0; + g_clear_handle_id(&timer_id, g_source_remove); if (event != NULL) { gdk_seat_ungrab(gdk_event_get_seat(event)); @@ -158,9 +155,8 @@ process_event(GtkWidget *widget, GdkEvent *event, gpointer data) last_mouse_position.invalid = TRUE; original_widget = NULL; - g_source_remove (timer_id); + g_clear_handle_id(&timer_id, g_source_remove); gdk_seat_ungrab(gdk_event_get_seat(event)); - timer_id = 0; { GtkWidget *history = data; |