[gnome-builder/wip/libide] libide: various cleanups
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: various cleanups
- Date: Sun, 15 Mar 2015 23:25:59 +0000 (UTC)
commit e1f111a7e887627d1e4eb32c01859a3abca79cc4
Author: Christian Hergert <christian hergert me>
Date: Sun Mar 15 16:23:44 2015 -0700
libide: various cleanups
libide/ide-back-forward-list.c | 7 ++-----
libide/ide-buffer-manager.c | 14 +++++++-------
libide/ide-project.c | 10 ++++++----
tests/test-ide-source-view.c | 12 ++++++++++--
4 files changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/libide/ide-back-forward-list.c b/libide/ide-back-forward-list.c
index 55a64d9..76b6a65 100644
--- a/libide/ide-back-forward-list.c
+++ b/libide/ide-back-forward-list.c
@@ -640,8 +640,7 @@ create_source_location (IdeBackForwardList *self,
{
IdeContext *context;
IdeProject *project;
- IdeFile *file;
- IdeSourceLocation *ret;
+ g_autoptr(IdeFile) file = NULL;
g_assert (IDE_IS_BACK_FORWARD_LIST (self));
g_assert (G_IS_FILE (gfile));
@@ -649,10 +648,8 @@ create_source_location (IdeBackForwardList *self,
context = ide_object_get_context (IDE_OBJECT (self));
project = ide_context_get_project (context);
file = ide_project_get_project_file (project, gfile);
- ret = ide_source_location_new (file, line, line_offset, 0);
- g_clear_object (&file);
- return ret;
+ return ide_source_location_new (file, line, line_offset, 0);
}
static void
diff --git a/libide/ide-buffer-manager.c b/libide/ide-buffer-manager.c
index afa5634..21cb6a1 100644
--- a/libide/ide-buffer-manager.c
+++ b/libide/ide-buffer-manager.c
@@ -600,13 +600,13 @@ ide_buffer_manager__load_file_read_cb (GObject *object,
* See ide_buffer_manager_load_file_finish() for how to complete this asynchronous request.
*/
void
-ide_buffer_manager_load_file_async (IdeBufferManager *self,
- IdeFile *file,
- gboolean force_reload,
- IdeProgress **progress,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ide_buffer_manager_load_file_async (IdeBufferManager *self,
+ IdeFile *file,
+ gboolean force_reload,
+ IdeProgress **progress,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
g_autoptr(GTask) task = NULL;
IdeContext *context;
diff --git a/libide/ide-project.c b/libide/ide-project.c
index 143963d..522f79a 100644
--- a/libide/ide-project.c
+++ b/libide/ide-project.c
@@ -186,13 +186,13 @@ ide_project_get_file_for_path (IdeProject *self,
g_return_val_if_fail (IDE_IS_PROJECT (self), NULL);
g_return_val_if_fail (path, NULL);
+ ide_project_reader_lock (self);
+
root = ide_project_get_root (self);
- if (!root)
- return NULL;
+ g_assert (IDE_IS_PROJECT_ITEM (root));
children = ide_project_item_get_children (root);
- if (!children)
- return NULL;
+ g_assert (children != NULL);
for (iter = g_sequence_get_begin_iter (children);
!g_sequence_iter_is_end (iter);
@@ -210,6 +210,8 @@ ide_project_get_file_for_path (IdeProject *self,
}
}
+ ide_project_reader_unlock (self);
+
if (!file)
{
IdeContext *context;
diff --git a/tests/test-ide-source-view.c b/tests/test-ide-source-view.c
index fbfdfbe..b1f4d5e 100644
--- a/tests/test-ide-source-view.c
+++ b/tests/test-ide-source-view.c
@@ -654,14 +654,22 @@ idedit__context_new_cb (GObject *object,
for (iter = gFilesToOpen; iter; iter = iter->next)
{
+ const gchar *path = iter->data;
IdeProject *project;
IdeFile *file;
project = ide_context_get_project (gContext);
- file = ide_project_get_file_for_path (project, iter->data);
+ g_assert (project);
+ g_assert (IDE_IS_PROJECT (project));
+
+ file = ide_project_get_file_for_path (project, path);
+ g_assert (file);
+ g_assert (IDE_IS_FILE (file));
ide_buffer_manager_load_file_async (bufmgr, file, FALSE, NULL, NULL,
idedit__bufmgr_load_file_cb, NULL);
+
+ g_object_unref (file);
}
gtk_window_present (gWindow);
@@ -733,7 +741,7 @@ main (int argc,
}
for (i = 1; i < argc; i++)
- gFilesToOpen = g_list_append (gFilesToOpen, argv [i]);
+ gFilesToOpen = g_list_append (gFilesToOpen, g_strdup (argv [i]));
project_dir = g_file_new_for_path (".");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]