diff options
author | Claudio Saavedra <csaavedra@igalia.com> | 2012-03-14 22:44:34 +0800 |
---|---|---|
committer | Claudio Saavedra <csaavedra@igalia.com> | 2012-06-13 23:19:11 +0800 |
commit | 14e79589e2990577107406fa9d91cdf3cc62c0cd (patch) | |
tree | e6c9fd8e353cd18b69764e417cb2c5c3c6fed700 /src | |
parent | 59c27f399380abedc9fc39ea18238448bf2b9230 (diff) | |
download | gsoc2013-epiphany-14e79589e2990577107406fa9d91cdf3cc62c0cd.tar gsoc2013-epiphany-14e79589e2990577107406fa9d91cdf3cc62c0cd.tar.gz gsoc2013-epiphany-14e79589e2990577107406fa9d91cdf3cc62c0cd.tar.bz2 gsoc2013-epiphany-14e79589e2990577107406fa9d91cdf3cc62c0cd.tar.lz gsoc2013-epiphany-14e79589e2990577107406fa9d91cdf3cc62c0cd.tar.xz gsoc2013-epiphany-14e79589e2990577107406fa9d91cdf3cc62c0cd.tar.zst gsoc2013-epiphany-14e79589e2990577107406fa9d91cdf3cc62c0cd.zip |
ephy-completion-model: use a cancellable with the history service
For two things: first, cancel pending operations if a new search term
is given before this is complete and, second, to cancel any operation
remaining during the model disposal.
https://bugzilla.gnome.org/show_bug.cgi?id=672073
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-completion-model.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c index 7ab7619dc..aa68bf7ea 100644 --- a/src/ephy-completion-model.c +++ b/src/ephy-completion-model.c @@ -34,6 +34,7 @@ G_DEFINE_TYPE (EphyCompletionModel, ephy_completion_model, GTK_TYPE_LIST_STORE) struct _EphyCompletionModelPrivate { EphyHistoryService *history_service; + GCancellable *cancellable; EphyNode *bookmarks; GSList *search_terms; @@ -72,6 +73,11 @@ ephy_completion_model_finalize (GObject *object) priv->search_terms = NULL; } + if (priv->cancellable) { + g_cancellable_cancel (priv->cancellable); + g_clear_object (&priv->cancellable); + } + G_OBJECT_CLASS (ephy_completion_model_parent_class)->finalize (object); } @@ -418,6 +424,7 @@ query_completed_cb (EphyHistoryService *service, g_slice_free (FindURLsData, user_data); g_list_free_full (urls, (GDestroyNotify)ephy_history_url_free); g_slist_free_full (list, (GDestroyNotify)free_potential_row); + g_clear_object (&priv->cancellable); } static void @@ -534,10 +541,16 @@ ephy_completion_model_update_for_string (EphyCompletionModel *model, user_data->callback = callback; user_data->user_data = data; + if (priv->cancellable) { + g_cancellable_cancel (priv->cancellable); + g_object_unref (priv->cancellable); + } + priv->cancellable = g_cancellable_new (); + ephy_history_service_find_urls (priv->history_service, 0, 0, MAX_COMPLETION_HISTORY_URLS, 0, - query, NULL, + query, priv->cancellable, (EphyHistoryJobCallback)query_completed_cb, user_data); } |