# HG changeset patch # User Dirk Olmes # Date 1411703933 -7200 # Node ID 1601d498cfb11bafea3417cb146f8a77b6c239f1 # Parent 2e5a12e3598e4e2fab2df4404e3fe0dd66482e65 close the log viewer after the process has terminated diff -r 2e5a12e3598e -r 1601d498cfb1 RemoteViewer/LogViewer.py --- 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() diff -r 2e5a12e3598e -r 1601d498cfb1 RemoteViewer/Viewer.py --- 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)