Marco Trevisan (Treviño) has proposed merging 
~3v1n0/ubuntu/+source/gnome-software:ubuntu/bionic into 
~ubuntu-desktop/ubuntu/+source/gnome-software:ubuntu/bionic.

Requested reviews:
  Ubuntu Desktop (ubuntu-desktop)
Related bugs:
  Bug #1756826 in nautilus (Ubuntu): "hangs when remote search provider 
performs expensive operation"
  https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1756826

For more details, see:
https://code.launchpad.net/~3v1n0/ubuntu/+source/gnome-software/+git/gnome-software/+merge/358489
-- 
Your team Ubuntu Desktop is requested to review the proposed merge of 
~3v1n0/ubuntu/+source/gnome-software:ubuntu/bionic into 
~ubuntu-desktop/ubuntu/+source/gnome-software:ubuntu/bionic.
diff --git a/debian/changelog b/debian/changelog
index 3aa0dbe..a258de6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+gnome-software (3.28.1-0ubuntu4.18.04.6) bionic; urgency=medium
+
+  * debian/patches/0026-shell-search-provider-implement-XUbuntuCancel.patch
+    - implement XUbuntuCancel to request pending search cancellation from
+      gnome-shell (LP: #1756826)
+
+ -- Marco Trevisan (Treviño) <[email protected]>  Thu, 08 Nov 2018 03:32:00 -0600
+
 gnome-software (3.28.1-0ubuntu4.18.04.5) bionic; urgency=medium
 
   * debian/patches/0023-Revert-Revert-flatpak-Use-list-of-related-apps-for-i.patch:
diff --git a/debian/patches/0026-shell-search-provider-implement-XUbuntuCancel.patch b/debian/patches/0026-shell-search-provider-implement-XUbuntuCancel.patch
new file mode 100644
index 0000000..f914b22
--- /dev/null
+++ b/debian/patches/0026-shell-search-provider-implement-XUbuntuCancel.patch
@@ -0,0 +1,176 @@
+From 2ac5ea28829ecaff2f8a180f2ef7eefbb07602d9 Mon Sep 17 00:00:00 2001
+From: Andrea Azzarone <[email protected]>
+Date: Fri, 7 Sep 2018 19:58:00 +0200
+Subject: [PATCH 24/26] shell-search-provider: implement XUbuntuCancel
+
+Implement XUbuntuCancel to request search cancellation. This is used by
+gnome-shell to cancel the current search e.g. if the search overview is
+closed.
+---
+ src/gs-shell-search-provider.c                | 74 +++++++++++++++----
+ src/shell-search-provider-dbus-interfaces.xml |  1 +
+ 2 files changed, 60 insertions(+), 15 deletions(-)
+
+diff --git a/src/gs-shell-search-provider.c b/src/gs-shell-search-provider.c
+index c01d72cb..8c1e0fda 100644
+--- a/src/gs-shell-search-provider.c
++++ b/src/gs-shell-search-provider.c
+@@ -45,6 +45,8 @@ struct _GsShellSearchProvider {
+ 	GsPluginLoader *plugin_loader;
+ 	GCancellable *cancellable;
+ 
++	PendingSearch *current_search;
++
+ 	GHashTable *metas_cache;
+ 	GsAppList *search_results;
+ };
+@@ -58,6 +60,17 @@ pending_search_free (PendingSearch *search)
+ 	g_slice_free (PendingSearch, search);
+ }
+ 
++static void
++cancel_current_search (GsShellSearchProvider *self)
++{
++	g_debug ("*** Cancel current search");
++
++	if (self->cancellable != NULL) {
++		g_cancellable_cancel (self->cancellable);
++		g_clear_object (&self->cancellable);
++	}
++}
++
+ static gint
+ search_sort_by_kudo_cb (GsApp *app1, GsApp *app2, gpointer user_data)
+ {
+@@ -71,6 +84,23 @@ search_sort_by_kudo_cb (GsApp *app1, GsApp *app2, gpointer user_data)
+ 	return 0;
+ }
+ 
++static void
++pending_search_finish (PendingSearch         *search,
++		       GDBusMethodInvocation *invocation,
++		       GVariant              *result)
++{
++	GsShellSearchProvider *self = search->provider;
++
++	g_dbus_method_invocation_return_value (invocation, result);
++
++	if (search == self->current_search) {
++		self->current_search = NULL;
++	}
++
++	pending_search_free (search);
++	g_application_release (g_application_get_default ());
++}
++
+ static void
+ search_done_cb (GObject *source,
+ 		GAsyncResult *res,
+@@ -87,10 +117,9 @@ search_done_cb (GObject *source,
+ 
+ 	list = gs_plugin_loader_job_process_finish (self->plugin_loader, res, NULL);
+ 	if (list == NULL) {
+-		g_dbus_method_invocation_return_value (search->invocation, g_variant_new ("(as)", NULL));
+-		pending_search_free (search);
+-		g_application_release (g_application_get_default ());
+-		return;	
++		pending_search_finish (search, search->invocation,
++				       g_variant_new ("(as)", NULL));
++		return;
+ 	}
+ 
+ 	/* sort by kudos, as there is no ratings data by default */
+@@ -106,10 +135,8 @@ search_done_cb (GObject *source,
+ 		/* cache this in case we need the app in GetResultMetas */
+ 		gs_app_list_add (self->search_results, app);
+ 	}
+-	g_dbus_method_invocation_return_value (search->invocation, g_variant_new ("(as)", &builder));
+ 
+-	pending_search_free (search);
+-	g_application_release (g_application_get_default ());
++	pending_search_finish (search, search->invocation, g_variant_new ("(as)", &builder));
+ }
+ 
+ static gchar *
+@@ -167,10 +194,7 @@ execute_search (GsShellSearchProvider  *self,
+ 
+ 	value = g_strjoinv (" ", terms);
+ 
+-	if (self->cancellable != NULL) {
+-		g_cancellable_cancel (self->cancellable);
+-		g_clear_object (&self->cancellable);
+-	}
++	cancel_current_search (self);
+ 
+ 	/* don't attempt searches for a single character */
+ 	if (g_strv_length (terms) == 1 &&
+@@ -183,6 +207,7 @@ execute_search (GsShellSearchProvider  *self,
+ 	pending_search->provider = self;
+ 	pending_search->invocation = g_object_ref (invocation);
+ 
++	self->current_search = pending_search;
+ 	g_application_hold (g_application_get_default ());
+ 	self->cancellable = g_cancellable_new ();
+ 
+@@ -334,6 +359,26 @@ handle_launch_search (GsShellSearchProvider2 	   *skeleton,
+ 	return TRUE;
+ }
+ 
++static gboolean
++handle_xubuntu_cancel (GsShellSearchProvider2 *skeleton,
++		       GDBusMethodInvocation  *invocation,
++		       gpointer                user_data)
++{
++	GsShellSearchProvider *self = GS_SHELL_SEARCH_PROVIDER (user_data);
++
++	g_debug ("*** XUbuntuCancel called");
++
++	if (self->current_search != NULL &&
++	    g_strcmp0 (g_dbus_method_invocation_get_sender (self->current_search->invocation),
++		       g_dbus_method_invocation_get_sender (invocation)) == 0) {
++		cancel_current_search (self);
++	}
++
++	gs_shell_search_provider2_complete_xubuntu_cancel (skeleton, invocation);
++
++	return TRUE;
++}
++
+ gboolean
+ gs_shell_search_provider_register (GsShellSearchProvider *self,
+                                    GDBusConnection       *connection,
+@@ -355,10 +400,7 @@ search_provider_dispose (GObject *obj)
+ {
+ 	GsShellSearchProvider *self = GS_SHELL_SEARCH_PROVIDER (obj);
+ 
+-	if (self->cancellable != NULL) {
+-		g_cancellable_cancel (self->cancellable);
+-		g_clear_object (&self->cancellable);
+-	}
++	cancel_current_search (self);
+ 
+ 	if (self->metas_cache != NULL) {
+ 		g_hash_table_destroy (self->metas_cache);
+@@ -393,6 +435,8 @@ gs_shell_search_provider_init (GsShellSearchProvider *self)
+ 			G_CALLBACK (handle_activate_result), self);
+ 	g_signal_connect (self->skeleton, "handle-launch-search",
+ 			G_CALLBACK (handle_launch_search), self);
++	g_signal_connect (self->skeleton, "handle-xubuntu-cancel",
++			G_CALLBACK (handle_xubuntu_cancel), self);
+ }
+ 
+ static void
+diff --git a/src/shell-search-provider-dbus-interfaces.xml b/src/shell-search-provider-dbus-interfaces.xml
+index f6840e2c..4529c1e8 100644
+--- a/src/shell-search-provider-dbus-interfaces.xml
++++ b/src/shell-search-provider-dbus-interfaces.xml
+@@ -40,5 +40,6 @@
+       <arg type='as' name='Terms' direction='in' />
+       <arg type='u' name='Timestamp' direction='in' />
+     </method>
++    <method name = 'XUbuntuCancel' />
+   </interface>
+ </node>
+-- 
+2.17.1
+
diff --git a/debian/patches/series b/debian/patches/series
index 1080728..3559058 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -32,3 +32,4 @@
 0023-Revert-Revert-flatpak-Use-list-of-related-apps-for-i.patch
 0024-flatpak-Check-if-a-related-app-is-installed-even-whe.patch
 0025-flatpak-Include-related-refs-to-the-app-s-runtime-on.patch
+0026-shell-search-provider-implement-XUbuntuCancel.patch
-- 
ubuntu-desktop mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-desktop

Reply via email to