[gnome-software/1731-search-for-apps-text-shows-up-instead-of-a-spinner-screen-randomly] gs-search-page: Ignore finished non-current searches
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1731-search-for-apps-text-shows-up-instead-of-a-spinner-screen-randomly] gs-search-page: Ignore finished non-current searches
- Date: Mon, 22 Aug 2022 10:57:54 +0000 (UTC)
commit 526853981daa30ad9689d26c9af2b5ded6b1fb36
Author: Milan Crha <mcrha redhat com>
Date: Mon Aug 22 12:54:23 2022 +0200
gs-search-page: Ignore finished non-current searches
The search can take various time and even the cancellable is cancelled
due to the search term change or anything like that, the code can be
far away from the place where the cancellable could be checked, which
means even the search was obsolete it could modify the content of the page.
Let the code check whether the finished search is still the current
search and ignore any result from it when it's an obsolete search.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1731
src/gs-search-page.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-search-page.c b/src/gs-search-page.c
index b86f7389a..5685688ba 100644
--- a/src/gs-search-page.c
+++ b/src/gs-search-page.c
@@ -96,21 +96,31 @@ gs_search_page_app_to_show_created_cb (GObject *source_object,
}
}
+typedef struct {
+ GsSearchPage *self;
+ GCancellable *search_cancellable;
+} GetSearchData;
+
static void
gs_search_page_get_search_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
guint i;
+ g_autofree GetSearchData *search_data = user_data;
GsApp *app;
- GsSearchPage *self = GS_SEARCH_PAGE (user_data);
+ GsSearchPage *self = search_data->self;
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
GtkWidget *app_row;
g_autoptr(GError) error = NULL;
g_autoptr(GsAppList) list = NULL;
- /* don't do the delayed spinner */
- gs_search_page_waiting_cancel (self);
+ if (search_data->search_cancellable == self->search_cancellable) {
+ /* don't do the delayed spinner */
+ gs_search_page_waiting_cancel (self);
+ } else {
+ return;
+ }
list = gs_plugin_loader_job_process_finish (plugin_loader, res, &error);
if (list == NULL) {
@@ -265,6 +275,7 @@ gs_search_page_load (GsSearchPage *self)
g_autoptr(GsPluginJob) plugin_job = NULL;
g_autoptr(GsAppQuery) query = NULL;
const gchar *keywords[2] = { NULL, };
+ GetSearchData *search_data;
self->changed = FALSE;
@@ -277,6 +288,10 @@ gs_search_page_load (GsSearchPage *self)
gs_search_page_waiting_cancel (self);
self->waiting_id = g_timeout_add (250, gs_search_page_waiting_show_cb, self);
+ search_data = g_new0 (GetSearchData, 1);
+ search_data->self = self;
+ search_data->search_cancellable = self->search_cancellable;
+
keywords[0] = self->value;
query = gs_app_query_new ("keywords", keywords,
"refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
@@ -298,7 +313,7 @@ gs_search_page_load (GsSearchPage *self)
gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
self->search_cancellable,
gs_search_page_get_search_cb,
- self);
+ search_data);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]