[gnome-builder/gnome-builder-3-26] vala-pack: avoid copying unsaved files from threads
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-26] vala-pack: avoid copying unsaved files from threads
- Date: Mon, 15 Jan 2018 03:13:57 +0000 (UTC)
commit 0f0aace40e8630574e95889fb1148f02685ee264
Author: Christian Hergert <chergert redhat com>
Date: Sun Jan 14 19:12:26 2018 -0800
vala-pack: avoid copying unsaved files from threads
We want to access these from the main thread to get a snapshot of the
modified buffers.
plugins/vala-pack/ide-vala-completion-provider.vala | 5 ++++-
plugins/vala-pack/ide-vala-index.vala | 11 +++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/plugins/vala-pack/ide-vala-completion-provider.vala
b/plugins/vala-pack/ide-vala-completion-provider.vala
index af08e0574..b69369219 100644
--- a/plugins/vala-pack/ide-vala-completion-provider.vala
+++ b/plugins/vala-pack/ide-vala-completion-provider.vala
@@ -80,6 +80,9 @@ namespace Ide
var index = service.index;
var unsaved_files = this._context.get_unsaved_files ();
+ /* make a copy for threaded access */
+ var unsaved_files_copy = unsaved_files.to_array ();
+
var cancellable = new GLib.Cancellable ();
context.cancelled.connect(() => {
cancellable.cancel ();
@@ -92,7 +95,7 @@ namespace Ide
iter.get_line () + 1,
iter.get_line_offset () + 1,
line,
- unsaved_files,
+ unsaved_files_copy,
this,
cancellable,
out res_line,
diff --git a/plugins/vala-pack/ide-vala-index.vala b/plugins/vala-pack/ide-vala-index.vala
index 7bedda4ef..a7a50d6a0 100644
--- a/plugins/vala-pack/ide-vala-index.vala
+++ b/plugins/vala-pack/ide-vala-index.vala
@@ -304,7 +304,9 @@ namespace Ide
var source_file = this.source_files[file];
source_file.get_mapped_contents ();
- this.apply_unsaved_files (unsaved_files_copy);
+ if (unsaved_files_copy != null)
+ this.apply_unsaved_files (unsaved_files_copy);
+
this.report.clear ();
this.reparse ();
if (this.report.get_errors () == 0 &&
@@ -328,20 +330,21 @@ namespace Ide
int line,
int column,
string? line_text,
- Ide.UnsavedFiles? unsaved_files,
+ GLib.GenericArray<Ide.UnsavedFile>? unsaved_files,
Ide.ValaCompletionProvider provider,
GLib.Cancellable? cancellable,
out int result_line,
out int result_column)
{
- var unsaved_files_copy = unsaved_files.to_array ();
var result = new Ide.CompletionResults (provider.query);
if ((cancellable == null) || !cancellable.is_cancelled ()) {
lock (this.code_context) {
Vala.CodeContext.push (this.code_context);
- this.apply_unsaved_files (unsaved_files_copy);
+ if (unsaved_files != null)
+ this.apply_unsaved_files (unsaved_files);
+
this.report.clear ();
this.reparse ();
if (this.report.get_errors () == 0 &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]