gui: delete log/applet docks instead of hiding them

This commit is contained in:
Sebastien Bourdeauducq 2016-03-10 10:34:37 +08:00
parent c5552f9009
commit 7f501820de
2 changed files with 11 additions and 4 deletions

View File

@ -85,7 +85,7 @@ class AppletIPCServer(AsyncioParentComm):
await asyncio.wait([self.server_task])
class AppletDock(QDockWidgetCloseDetect):
class _AppletDock(QDockWidgetCloseDetect):
def __init__(self, datasets_sub, uid, name, command):
QDockWidgetCloseDetect.__init__(self, "Applet: " + name)
self.setObjectName("applet" + str(uid))
@ -137,7 +137,7 @@ class AppletDock(QDockWidgetCloseDetect):
def fix_initial_size(self):
self.embed_window.resize(self.embed_widget.size())
async def terminate(self):
async def terminate(self, delete_self=True):
if self.starting_stopping:
return
self.starting_stopping = True
@ -163,8 +163,12 @@ class AppletDock(QDockWidgetCloseDetect):
self.starting_stopping = False
if delete_self:
self.setParent(None)
self.deleteLater()
async def restart(self):
await self.terminate()
await self.terminate(False)
await self.start()
@ -235,7 +239,7 @@ class AppletsDock(QtWidgets.QDockWidget):
self.table.cellChanged.connect(self.cell_changed)
def create(self, uid, name, command):
dock = AppletDock(self.datasets_sub, uid, name, command)
dock = _AppletDock(self.datasets_sub, uid, name, command)
self.main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)
dock.setFloating(True)
asyncio.ensure_future(dock.start())

View File

@ -303,6 +303,9 @@ class LogDockManager:
return dock
def on_dock_closed(self, name):
dock = self.docks[name]
dock.setParent(None)
dock.deleteLater()
del self.docks[name]
self.update_closable()