[gnome-builder/gnome-builder-3-26] spellcheck: be defensive against race conditions
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-26] spellcheck: be defensive against race conditions
- Date: Mon, 9 Oct 2017 20:42:59 +0000 (UTC)
commit d2e23d53ce1b3e33811c160d27eb6a31069e7a81
Author: Christian Hergert <chergert redhat com>
Date: Mon Oct 9 13:30:48 2017 -0700
spellcheck: be defensive against race conditions
If we are in a situation where the buffer is already in the dispose
phase, we can't do much about it here. Our view should be cleaned up
shortly. Just short circuit and wait for unload.
plugins/spellcheck/gbp-spell-editor-view-addin.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/plugins/spellcheck/gbp-spell-editor-view-addin.c
b/plugins/spellcheck/gbp-spell-editor-view-addin.c
index a44282d..2b48afa 100644
--- a/plugins/spellcheck/gbp-spell-editor-view-addin.c
+++ b/plugins/spellcheck/gbp-spell-editor-view-addin.c
@@ -129,8 +129,16 @@ gbp_spell_editor_view_addin_load (IdeEditorViewAddin *addin,
g_assert (IDE_IS_BUFFER (buffer));
buffer_addin = ide_buffer_addin_find_by_module_name (buffer, "spellcheck-plugin");
- g_assert (buffer_addin != NULL);
- g_assert (GBP_IS_SPELL_BUFFER_ADDIN (buffer_addin));
+
+ if (!GBP_IS_SPELL_BUFFER_ADDIN (buffer_addin))
+ {
+ /* We might find ourselves in a race here and the buffer
+ * addins are already in destruction. Therefore, silently
+ * fail any further setup.
+ */
+ g_warning ("Failed to locate buffer addin, spellcheck disabled");
+ return;
+ }
wrapper = gspell_text_view_get_from_gtk_text_view (GTK_TEXT_VIEW (source_view));
g_assert (wrapper != NULL);
@@ -175,8 +183,11 @@ gbp_spell_editor_view_addin_unload (IdeEditorViewAddin *addin,
gtk_widget_insert_action_group (GTK_WIDGET (view), "spellcheck", NULL);
- dzl_binding_group_set_source (self->buffer_addin_bindings, NULL);
- g_clear_object (&self->buffer_addin_bindings);
+ if (self->buffer_addin_bindings != NULL)
+ {
+ dzl_binding_group_set_source (self->buffer_addin_bindings, NULL);
+ g_clear_object (&self->buffer_addin_bindings);
+ }
g_clear_object (&self->navigator);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]