Browse Source

Closing the editor window calls deleteWindow() on the app.

startup
Ben Niemann 3 years ago
parent
commit
107a8f5fa8
  1. 8
      noisicaa/ui/editor_app.py
  2. 12
      noisicaa/ui/editor_window.py

8
noisicaa/ui/editor_app.py

@ -395,10 +395,16 @@ class EditorApp(ui_base.AbstractEditorApp):
async def createWindow(self) -> editor_window.EditorWindow:
win = editor_window.EditorWindow(context=self.context)
await win.setup()
win.show()
self.__windows.append(win)
return win
async def deleteWindow(self, win: editor_window.EditorWindow) -> None:
self.__windows.remove(win)
await win.cleanup()
if not self.__windows:
self.quit()
def quit(self, exit_code: int = 0) -> None:
# TODO: quit() is not a method of ProcessBase, only in UIProcess. Find some way to
# fix that without a cyclic import.

12
noisicaa/ui/editor_window.py

@ -212,9 +212,11 @@ class EditorWindow(ui_base.AbstractEditorWindow):
self.app.settings.value('mainwindow/state', b''))
async def setup(self) -> None:
pass
self.show()
async def cleanup(self) -> None:
self.hide()
if self.__setup_progress_fade_task is not None:
self.__setup_progress_fade_task.cancel()
try:
@ -227,8 +229,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
self.__engine_state_listener.remove()
self.__engine_state_listener = None
self.hide()
while self.__project_tabs.count() > 0:
tab = cast(ProjectTabPage, self.__project_tabs.widget(0))
view = tab.projectView()
@ -236,8 +236,6 @@ class EditorWindow(ui_base.AbstractEditorWindow):
await view.cleanup()
self.__project_tabs.removeTab(0)
self.close()
def audioprocReady(self) -> None:
self.__engine_state_listener = self.audioproc_client.engine_state_changed.add(
self.__engineStateChanged)
@ -476,8 +474,8 @@ class EditorWindow(ui_base.AbstractEditorWindow):
def closeEvent(self, event: QtGui.QCloseEvent) -> None:
logger.info("CloseEvent received")
event.accept()
self.app.quit()
event.ignore()
self.call_async(self.app.deleteWindow(self))
def setCurrentProjectView(self, view: Optional[project_view.ProjectView]) -> None:
if view == self.__current_project_view:

Loading…
Cancel
Save