gui: terminate connection on tab close
+ add method to explicitly terminate connection on qsecnode * disconnect explicitly when closing tabs Change-Id: I00af5fb296e1499b88eafc033f62fdcc1131a145 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30677 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
parent
a1271b7268
commit
8c6f1a21ab
@ -493,6 +493,8 @@ class SecopClient(ProxyClient):
|
|||||||
self.txq.get(False)
|
self.txq.get(False)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
if self.io:
|
||||||
|
self.io.shutdown()
|
||||||
if self._txthread:
|
if self._txthread:
|
||||||
self.txq.put(None) # shutdown marker
|
self.txq.put(None) # shutdown marker
|
||||||
self._txthread.join()
|
self._txthread.join()
|
||||||
|
@ -107,3 +107,6 @@ class QSECNode(QObject):
|
|||||||
|
|
||||||
def unhandledMessage(self, action, specifier, data):
|
def unhandledMessage(self, action, specifier, data):
|
||||||
self.unhandledMsg.emit('%s %s %r' % (action, specifier, data))
|
self.unhandledMsg.emit('%s %s %r' % (action, specifier, data))
|
||||||
|
|
||||||
|
def terminate_connection(self):
|
||||||
|
self.conn.disconnect()
|
||||||
|
@ -229,6 +229,7 @@ class MainWindow(QMainWindow):
|
|||||||
try:
|
try:
|
||||||
node = self.tab.widget(index).getSecNode()
|
node = self.tab.widget(index).getSecNode()
|
||||||
# disconnect node from all events
|
# disconnect node from all events
|
||||||
|
node.terminate_connection()
|
||||||
self._nodes.pop(node.nodename)
|
self._nodes.pop(node.nodename)
|
||||||
self.log.debug("Closing tab with node %s" % node.nodename)
|
self.log.debug("Closing tab with node %s" % node.nodename)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -247,6 +248,5 @@ class MainWindow(QMainWindow):
|
|||||||
def _onQuit(self):
|
def _onQuit(self):
|
||||||
for node in self._nodes.values():
|
for node in self._nodes.values():
|
||||||
# this is only qt signals deconnecting!
|
# this is only qt signals deconnecting!
|
||||||
# TODO: terminate node.conn explicitly?
|
node.terminate_connection()
|
||||||
node.disconnect()
|
|
||||||
self.logwin.onClose()
|
self.logwin.onClose()
|
||||||
|
@ -473,7 +473,7 @@ class TearOffTabWidget(QTabWidget):
|
|||||||
return widget
|
return widget
|
||||||
|
|
||||||
def close_current(self):
|
def close_current(self):
|
||||||
self.removeTab(self.currentIndex())
|
self.tabCloseRequested.emit(self.currentIndex())
|
||||||
|
|
||||||
|
|
||||||
class DetachedWindow(QMainWindow):
|
class DetachedWindow(QMainWindow):
|
||||||
|
@ -86,6 +86,9 @@ class AsynConn:
|
|||||||
if cls.scheme:
|
if cls.scheme:
|
||||||
cls.SCHEME_MAP[cls.scheme] = cls
|
cls.SCHEME_MAP[cls.scheme] = cls
|
||||||
|
|
||||||
|
def shutdown(self):
|
||||||
|
"""prepare connection for disconnect, can be empty"""
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -177,6 +180,10 @@ class AsynTcp(AsynConn):
|
|||||||
# indicate that retrying might make sense
|
# indicate that retrying might make sense
|
||||||
raise CommunicationFailedError(str(e)) from None
|
raise CommunicationFailedError(str(e)) from None
|
||||||
|
|
||||||
|
def shutdown(self):
|
||||||
|
if self.connection:
|
||||||
|
self.connection.shutdown(socket.SHUT_RDWR)
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
if self.connection:
|
if self.connection:
|
||||||
closeSocket(self.connection)
|
closeSocket(self.connection)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user