From 53f9158f25eb59f18d52e45f9adb5c013f467b75 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 24 Jan 2017 08:59:00 -0200 Subject: [PATCH] search-view: only decrease search counter when something is removed Because we were blindlessly decreasing the search hit counter without considering that we could've not removed anything, the search hit counter is going nuts. Fix that by properly checking if something was removed, and only decrease the search hit counter when that happens. --- src/gcal-search-view.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gcal-search-view.c b/src/gcal-search-view.c index 4100a603..f5ad3561 100644 --- a/src/gcal-search-view.c +++ b/src/gcal-search-view.c @@ -638,22 +638,27 @@ gcal_search_view_component_removed (ECalDataModelSubscriber *subscriber, else uuid = g_strdup_printf ("%s:%s", e_source_get_uid (source), uid); - // Lookup the RowEventData + /* Lookup the RowEventData */ row_data = g_hash_table_lookup (view->uuid_to_event, uuid); - /* Removing the given RowEventData entry will - * call free_row_data, which removes the row - * from the listbox and also free the uuid. - */ - if (row_data) - g_hash_table_remove (view->uuid_to_event, uuid); + /* We didn't add this event, so there's nothing to do */ + if (!row_data) + goto out; - g_free (uuid); + /* + * Removing the given RowEventData entry will call free_row_data(), + * which removes the row from the listbox and also frees the hashtable's + * uuid. + */ + g_hash_table_remove (view->uuid_to_event, uuid); /* show 'no results' */ view->num_results--; update_view (GCAL_SEARCH_VIEW (subscriber)); + +out: + g_free (uuid); } static void