[gnome-builder] makecache: be kind to files not in the project



commit 55ef467a4deb583b4b71aa6fca8092193e57a6c4
Author: Christian Hergert <christian hergert me>
Date:   Thu May 14 20:28:28 2015 -0700

    makecache: be kind to files not in the project
    
    This happens when you jump into things found in /usr/include, etc.

 libide/autotools/ide-makecache.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/libide/autotools/ide-makecache.c b/libide/autotools/ide-makecache.c
index 3652117..db9fccb 100644
--- a/libide/autotools/ide-makecache.c
+++ b/libide/autotools/ide-makecache.c
@@ -1106,9 +1106,20 @@ ide_makecache_get_file_targets_dispatch (EggTaskCache  *cache,
   g_assert (G_IS_TASK (task));
 
   lookup = g_slice_new0 (FileTargetsLookup);
-  lookup->path = ide_makecache_get_relative_path (self, file);
   lookup->mapped = g_mapped_file_ref (self->mapped);
 
+  if (!(lookup->path = ide_makecache_get_relative_path (self, file)) &&
+      !(lookup->path = g_file_get_path (file)) &&
+      !(lookup->path = g_file_get_basename (file)))
+    {
+      file_targets_lookup_free (lookup);
+      g_task_return_new_error (task,
+                               G_IO_ERROR,
+                               G_IO_ERROR_INVALID_FILENAME,
+                               "Failed to extract filename.");
+      return;
+    }
+
   g_task_set_task_data (task, lookup, file_targets_lookup_free);
 
   /* throttle via the compiler thread pool */
@@ -1195,7 +1206,18 @@ ide_makecache_get_file_flags_dispatch (EggTaskCache  *cache,
   lookup = g_slice_new0 (FileFlagsLookup);
   lookup->self = g_object_ref (self);
   lookup->file = g_object_ref (file);
-  lookup->relative_path = ide_makecache_get_relative_path (self, file);
+
+  if (!(lookup->relative_path = ide_makecache_get_relative_path (self, file)) &&
+      !(lookup->relative_path = g_file_get_path (file)) &&
+      !(lookup->relative_path = g_file_get_basename (file)))
+    {
+      file_flags_lookup_free (lookup);
+      g_task_return_new_error (task,
+                               G_IO_ERROR,
+                               G_IO_ERROR_INVALID_FILENAME,
+                               "Failed to extract filename.");
+      return;
+    }
 
   g_task_set_task_data (task, lookup, file_flags_lookup_free);
 


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