[gedit] tools: fix pipe handling
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] tools: fix pipe handling
- Date: Tue, 2 Apr 2013 15:04:35 +0000 (UTC)
commit 73fea5fd0e917f0638182b690b4207eca569f773
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Tue Apr 2 17:00:11 2013 +0200
tools: fix pipe handling
plugins/externaltools/tools/capture.py | 12 ++++++++----
plugins/externaltools/tools/functions.py | 4 ++--
2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/plugins/externaltools/tools/capture.py b/plugins/externaltools/tools/capture.py
index 81fa79f..117386f 100644
--- a/plugins/externaltools/tools/capture.py
+++ b/plugins/externaltools/tools/capture.py
@@ -126,7 +126,7 @@ class Capture(GObject.Object):
self.idle_write_id = GLib.idle_add(self.idle_write_chunk)
# Wait for the process to complete
- GLib.child_watch_add(self.pipe.pid, self.on_child_end)
+ GLib.child_watch_add(GLib.PRIORITY_DEFAULT, self.pipe.pid, self.on_child_end)
def idle_write_chunk(self):
if not self.pipe:
@@ -164,6 +164,11 @@ class Capture(GObject.Object):
self.read_buffer = ''
+ def close_pipe(self, source):
+ if self.pipe:
+ source.shutdown(True)
+ self.pipe = None
+
def on_output(self, source, condition):
if condition & (GObject.IO_IN | GObject.IO_PRI):
line = source.read()
@@ -189,15 +194,14 @@ class Capture(GObject.Object):
else:
self.emit('stderr-line', line)
else:
- source.close()
self.process_read_buffer(source)
- self.pipe = None
+ self.close_pipe(source)
return False
if condition & ~(GObject.IO_IN | GObject.IO_PRI):
self.process_read_buffer(source)
- self.pipe = None
+ self.close_pipe(source)
return False
else:
diff --git a/plugins/externaltools/tools/functions.py b/plugins/externaltools/tools/functions.py
index 5acf50d..8b394c2 100644
--- a/plugins/externaltools/tools/functions.py
+++ b/plugins/externaltools/tools/functions.py
@@ -196,12 +196,12 @@ def run_external_tool(window, panel, node):
document.begin_user_action()
capture.connect('stderr-line', capture_stderr_line_panel, panel)
- capture.connect('begin-execute', capture_begin_execute_panel, panel, view, node.name)
+ capture.connect('begin-execute', capture_begin_execute_panel, panel, view, node.name)
capture.connect('end-execute', capture_end_execute_panel, panel, view, output_type)
# Run the command
capture.execute()
-
+
if output_type != 'nothing':
document.end_user_action()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]