Mercurial > hg > RemoteViewer
changeset 26:1601d498cfb1
close the log viewer after the process has terminated
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 26 Sep 2014 05:58:53 +0200 |
parents | 2e5a12e3598e |
children | c0ef1794e275 |
files | RemoteViewer/LogViewer.py RemoteViewer/Viewer.py |
diffstat | 2 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/RemoteViewer/LogViewer.py Fri Sep 26 04:57:10 2014 +0200 +++ b/RemoteViewer/LogViewer.py Fri Sep 26 05:58:53 2014 +0200 @@ -4,12 +4,19 @@ class LogViewer(QDialog): appendSignal = pyqtSignal(['QString']) + closeSignal = pyqtSignal() def __init__(self): super(LogViewer, self).__init__() self.ui = Ui_LogViewer() self.ui.setupUi(self) self.appendSignal.connect(self.ui.logText.appendPlainText) + self.closeSignal.connect(self.close) def append(self, line): + """Use Qt's signal/slot mechanism as this method is called from a different thread""" self.appendSignal.emit(line) + + def finish(self): + """Use Qt's signal/slot mechanism as this method is called from a different thread""" + self.closeSignal.emit()
--- a/RemoteViewer/Viewer.py Fri Sep 26 04:57:10 2014 +0200 +++ b/RemoteViewer/Viewer.py Fri Sep 26 05:58:53 2014 +0200 @@ -4,14 +4,19 @@ from .LogViewer import LogViewer class ReadThread(Thread): - def __init__(self, output, viewer): + def __init__(self, process, viewer): super(ReadThread, self).__init__() self.daemon = True - self.output = output + self.process = process self.viewer = viewer def run(self): - for line in iter(self.output.readline, b''): + loop = True + while loop: + if self.process.poll() is not None: + self.viewer.finish() + loop = False + line = self.process.stdout.readline() line = line.decode('utf-8') line = line.rstrip('\n') self.viewer.append(line) @@ -29,7 +34,7 @@ def __startLogThread(self): logViewer = self.__createLogViewer() - readThread = ReadThread(self.process.stdout, logViewer) + readThread = ReadThread(self.process, logViewer) readThread.start() logViewer.exec_() @@ -57,7 +62,7 @@ class FreeRdp(AbstractViewer): def buildCommand(self): - self.command = ['xfreerdp', '+clipboard' ] + self.command = ['xfreerdp', '+clipboard'] self.append('/v:', self.connection.host) self.append('/t:', self.connection.displayString()) self.append('/u:', self.connection.user)