diff options
author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2018-10-04 18:19:31 +0200 |
---|---|---|
committer | Marco Trevisan <mail@3v1n0.net> | 2018-10-08 13:05:14 +0000 |
commit | 4c6d4eea995a66e80fb21ee83b66954d1ce71c08 (patch) | |
tree | 5aa30c733d1961812fb284fb4ce884e8ad7a3cef /src | |
parent | 284c5a8612bca9fe1badccf172982eeab808a2e1 (diff) | |
download | nautilus-4c6d4eea995a66e80fb21ee83b66954d1ce71c08.tar.gz |
search-engine-recent: remove add hits idle on finalize
Use a new function to initialize it without having to redo the same
thing twice.
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-search-engine-recent.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/nautilus-search-engine-recent.c b/src/nautilus-search-engine-recent.c index 0de060f83..8cc7b88f0 100644 --- a/src/nautilus-search-engine-recent.c +++ b/src/nautilus-search-engine-recent.c @@ -42,6 +42,7 @@ struct _NautilusSearchEngineRecent NautilusQuery *query; GCancellable *cancellable; GtkRecentManager *recent_manager; + guint add_hits_idle_id; }; static void nautilus_search_provider_init (NautilusSearchProviderInterface *iface); @@ -71,10 +72,8 @@ nautilus_search_engine_recent_finalize (GObject *object) { NautilusSearchEngineRecent *self = NAUTILUS_SEARCH_ENGINE_RECENT (object); - if (self->cancellable) - { - g_cancellable_cancel (self->cancellable); - } + g_clear_handle_id (&self->add_hits_idle_id, g_source_remove); + g_cancellable_cancel (self->cancellable); g_clear_object (&self->query); g_clear_object (&self->cancellable); @@ -96,6 +95,8 @@ search_thread_add_hits_idle (gpointer user_data) NautilusSearchEngineRecent *self = search_hits->recent; NautilusSearchProvider *provider = NAUTILUS_SEARCH_PROVIDER (self); + self->add_hits_idle_id = 0; + if (!g_cancellable_is_cancelled (self->cancellable)) { nautilus_search_provider_hits_added (provider, search_hits->hits); @@ -115,6 +116,24 @@ search_thread_add_hits_idle (gpointer user_data) return FALSE; } +static void +search_add_hits_idle (NautilusSearchEngineRecent *self, + GList *hits) +{ + SearchHitsData *search_hits; + + if (self->add_hits_idle_id != 0) + { + return; + } + + search_hits = g_new0 (SearchHitsData, 1); + search_hits->recent = self; + search_hits->hits = hits; + + self->add_hits_idle_id = g_idle_add (search_thread_add_hits_idle, search_hits); +} + static gboolean is_file_valid_recursive (NautilusSearchEngineRecent *self, GFile *file, @@ -296,11 +315,7 @@ recent_thread_func (gpointer user_data) } } - search_hits = g_new0 (SearchHitsData, 1); - search_hits->recent = self; - search_hits->hits = hits; - - g_idle_add (search_thread_add_hits_idle, search_hits); + search_add_hits_idle (self, hits); g_list_free_full (recent_items, (GDestroyNotify) gtk_recent_info_unref); g_list_free_full (mime_types, g_free); @@ -324,11 +339,7 @@ nautilus_search_engine_recent_start (NautilusSearchProvider *provider) nautilus_query_get_recursive (self->query), location)) { - SearchHitsData *search_hits; - search_hits = g_new0 (SearchHitsData, 1); - search_hits->recent = g_object_ref (self); - - g_idle_add (search_thread_add_hits_idle, search_hits); + search_add_hits_idle (self, NULL); return; } |