[gnome-builder] todo: check ignored status in worker thread
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] todo: check ignored status in worker thread
- Date: Sat, 14 Oct 2017 00:12:11 +0000 (UTC)
commit 58eb9cca33f9cca7ed8e6bb71038c60dc19cdf6b
Author: Christian Hergert <chergert redhat com>
Date: Fri Oct 13 17:11:06 2017 -0700
todo: check ignored status in worker thread
Now that IdeVcs guarantees thread-safety for
ide_vcs_is_ingored(), we can check for ignored files from our
worker thread instead of the main loop.
src/plugins/todo/gbp-todo-model.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/plugins/todo/gbp-todo-model.c b/src/plugins/todo/gbp-todo-model.c
index 0858fe8..005aac6 100644
--- a/src/plugins/todo/gbp-todo-model.c
+++ b/src/plugins/todo/gbp-todo-model.c
@@ -134,17 +134,11 @@ static void
gbp_todo_model_merge (GbpTodoModel *self,
GbpTodoItem *item)
{
- const gchar *path;
GtkTreeIter iter;
g_assert (GBP_IS_TODO_MODEL (self));
g_assert (GBP_IS_TODO_ITEM (item));
- path = gbp_todo_item_get_path (item);
-
- if (ide_vcs_path_is_ignored (self->vcs, path, NULL))
- return;
-
gtk_list_store_prepend (GTK_LIST_STORE (self), &iter);
gtk_list_store_set (GTK_LIST_STORE (self), &iter, 0, item, -1);
}
@@ -301,6 +295,7 @@ gbp_todo_model_mine_worker (GTask *task,
g_autoptr(GBytes) bytes = NULL;
g_autoptr(GTimer) timer = g_timer_new ();
g_autofree gchar *path = NULL;
+ GbpTodoModel *self = source_object;
IdeLineReader reader;
ResultInfo *info;
gchar *stdoutstr = NULL;
@@ -311,7 +306,7 @@ gbp_todo_model_mine_worker (GTask *task,
gsize len;
g_assert (G_IS_TASK (task));
- g_assert (GBP_IS_TODO_MODEL (source_object));
+ g_assert (GBP_IS_TODO_MODEL (self));
g_assert (G_IS_FILE (file));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
@@ -405,7 +400,20 @@ gbp_todo_model_mine_worker (GTask *task,
if (g_str_has_prefix (line, "--"))
{
if (item != NULL)
- g_ptr_array_add (items, g_steal_pointer (&item));
+ {
+ const gchar *pathstr = gbp_todo_item_get_path (item);
+
+ /*
+ * self->vcs is only set at construction, so safe to
+ * access via a worker thread. ide_vcs_path_is_ignored()
+ * is expected to be thread-safe as well.
+ */
+ if (!ide_vcs_path_is_ignored (self->vcs, pathstr, NULL))
+ g_ptr_array_add (items, g_steal_pointer (&item));
+ else
+ g_clear_object (&item);
+ }
+
continue;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]