[gnome-builder] code-assist: cancel pending bus operations when reinitializing
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] code-assist: cancel pending bus operations when reinitializing
- Date: Fri, 21 Nov 2014 10:19:59 +0000 (UTC)
commit 5ab4fdcbde2c12654736b73e830517cf73742cc9
Author: Christian Hergert <christian hergert me>
Date: Fri Nov 21 02:19:32 2014 -0800
code-assist: cancel pending bus operations when reinitializing
We can still have an operation in flight when we change the buffer
language (causing code-assist to reload). This saves us from having
two of those in flight at once.
src/editor/gb-editor-code-assistant.c | 16 ++++++++++++++--
src/editor/gb-editor-tab-private.h | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-editor-code-assistant.c b/src/editor/gb-editor-code-assistant.c
index 4c38b9a..c8ed7f4 100644
--- a/src/editor/gb-editor-code-assistant.c
+++ b/src/editor/gb-editor-code-assistant.c
@@ -319,7 +319,7 @@ gb_editor_code_assistant_parse (gpointer user_data)
priv->gca_tmpfile,
cursor,
options,
- NULL,
+ priv->gca_cancellable,
gb_editor_code_assistant_parse_cb,
g_object_ref (tab));
@@ -743,10 +743,16 @@ gb_editor_code_assistant_init (GbEditorTab *tab)
gWarningPixbuf = get_pixbuf_sized_for (GTK_WIDGET (tab->priv->source_view),
"dialog-warning-symbolic");
+ /* destroy is safe to call on zeroed structures */
+ gb_editor_code_assistant_destroy (tab);
+
lang_id = get_language (tab->priv->source_view);
if (!lang_id)
EXIT;
+ if (!tab->priv->gca_cancellable)
+ tab->priv->gca_cancellable = g_cancellable_new ();
+
name = g_strdup_printf ("org.gnome.CodeAssist.v1.%s", lang_id);
path = g_strdup_printf ("/org/gnome/CodeAssist/v1/%s", lang_id);
@@ -759,7 +765,7 @@ gb_editor_code_assistant_init (GbEditorTab *tab)
if (!service)
gca_service_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
- name, path, NULL,
+ name, path, tab->priv->gca_cancellable,
service_proxy_new_cb,
g_object_ref (tab));
else
@@ -782,6 +788,12 @@ gb_editor_code_assistant_destroy (GbEditorTab *tab)
priv = tab->priv;
+ if (priv->gca_cancellable)
+ {
+ g_cancellable_cancel (priv->gca_cancellable);
+ g_clear_object (&priv->gca_cancellable);
+ }
+
g_clear_object (&priv->gca_service);
g_clear_pointer (&priv->gca_error_lines, g_hash_table_unref);
diff --git a/src/editor/gb-editor-tab-private.h b/src/editor/gb-editor-tab-private.h
index 7194b1d..fd597b6 100644
--- a/src/editor/gb-editor-tab-private.h
+++ b/src/editor/gb-editor-tab-private.h
@@ -94,6 +94,7 @@ struct _GbEditorTabPrivate
/*
* Code Assistance.
*/
+ GCancellable *gca_cancellable;
GcaService *gca_service;
gchar *gca_tmpfile;
gint gca_tmpfd;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]