[gnome-builder] file: don't cache files without contexts



commit 9dedffe960ef376840afe5d92d4be57f0c7bf4a7
Author: Christian Hergert <chergert redhat com>
Date:   Sun Jan 14 18:49:23 2018 -0800

    file: don't cache files without contexts
    
    We don't want to cache IdeFile unless they have a context set. Otherwise
    we end up giving out IdeFile without a context, which is non-ideal.

 src/libide/files/ide-file.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/files/ide-file.c b/src/libide/files/ide-file.c
index 3a31b5a18..82a95b753 100644
--- a/src/libide/files/ide-file.c
+++ b/src/libide/files/ide-file.c
@@ -716,7 +716,13 @@ ide_file_new (IdeContext *context,
                           "context", context,
                           "file", file,
                           NULL);
-      g_hash_table_insert (files_cache, file, ret);
+
+      /* Only cache this item if has an IdeContext. We might want
+       * to make a file cache per-context, but we can hold off on
+       * that until we know we need it.
+       */
+      if (context != NULL)
+        g_hash_table_insert (files_cache, file, ret);
     }
 
   G_UNLOCK (files_cache);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]