def closeEvent(self, event): shouldSave = self.shouldSave() if shouldSave == QMessageBox.Yes: if not self.save(): event.ignore() return elif shouldSave == QMessageBox.Discard: event.ignore() return self.tick_timer.stop() self.tick_timer.timeout.disconnect() EditorHistory().shutdown() self.canvasWidget.shoutDown() # save editor config settings = ConfigManager().getSettings("APP_STATE") # clear file each time to capture opened dock tools settings.clear() settings.sync() settings.beginGroup('Editor') settings.setValue("geometry", self.saveGeometry()) settings.setValue("state", self.saveState()) settings.endGroup() # save tools state settings.beginGroup('Tools') for tool in self._tools: if isinstance(tool, ShelfTool): settings.beginGroup("ShelfTools") settings.beginGroup(tool.name()) tool.saveState(settings) settings.endGroup() settings.endGroup() if isinstance(tool, DockTool): settings.beginGroup("DockTools") settings.beginGroup(tool.uniqueName()) tool.saveState(settings) settings.endGroup() settings.endGroup() tool.onDestroy() settings.endGroup() settings.sync() # remove temp directory if exists if os.path.exists(self.currentTempDir): shutil.rmtree(self.currentTempDir) SingletonDecorator.destroyAll() PyFlow.appInstance = None QMainWindow.closeEvent(self, event)
def closeEvent(self, event): self.tick_timer.stop() self.tick_timer.timeout.disconnect() EditorHistory().shutdown() self.canvasWidget.shoutDown() # save editor config settings = ConfigManager().getSettings("APP_STATE") # clear file each time to capture opened dock tools settings.clear() settings.sync() settings.beginGroup('Editor') settings.setValue("geometry", self.saveGeometry()) settings.setValue("state", self.saveState()) settings.endGroup() # save tools state settings.beginGroup('Tools') for tool in self._tools: if isinstance(tool, ShelfTool): settings.beginGroup("ShelfTools") settings.beginGroup(tool.name()) tool.saveState(settings) settings.endGroup() settings.endGroup() if isinstance(tool, DockTool): settings.beginGroup("DockTools") settings.beginGroup(tool.uniqueName()) tool.saveState(settings) settings.endGroup() settings.endGroup() tool.onDestroy() settings.endGroup() settings.sync() # remove temp directory if exists if os.path.exists(self.currentTempDir): shutil.rmtree(self.currentTempDir) # TODO: Use "Borg" pattern to destroy all singletons at once EditorHistory.destroy() GraphManagerSingleton.destroy() ConfigManager.destroy() PreferencesWindow.destroy() PyFlow.appInstance = None QMainWindow.closeEvent(self, event)