def terminate(): import brailleViewer brailleViewer.destroyBrailleViewer() # prevent race condition with object deletion # prevent deletion of the object while we work on it. _SettingsDialog = settingsDialogs.SettingsDialog nonWeak: typing.Dict[_SettingsDialog, _SettingsDialog] = dict(_SettingsDialog._instances) for instance, state in nonWeak.items(): if state is _SettingsDialog.DialogState.DESTROYED: log.error( "Destroyed but not deleted instance of gui.SettingsDialog exists" f": {instance.title} - {instance.__class__.__qualname__} - {instance}" ) else: log.debug("Exiting NVDA with an open settings dialog: {!r}".format( instance)) global mainFrame # This is called after the main loop exits because WM_QUIT exits the main loop # without destroying all objects correctly and we need to support WM_QUIT. # Therefore, any request to exit should exit the main loop. safeAppExit() # #4460: We need another iteration of the main loop # so that everything (especially the TaskBarIcon) is cleaned up properly. # ProcessPendingEvents doesn't seem to work, but MainLoop does. # Because the top window gets destroyed, # MainLoop thankfully returns pretty quickly. wx.GetApp().MainLoop() mainFrame = None
def handleNVDAModuleCleanupBeforeGUIExit(): """ Terminates various modules that rely on the GUI. This should be used before closing all windows and terminating the GUI """ import brailleViewer # before the GUI is terminated we must terminate the update checker if updateCheck: _terminate(updateCheck) # The core is expected to terminate, so we should not treat this as a crash _terminate(watchdog) # plugins must be allowed to close safely before we terminate the GUI as dialogs may be unsaved _terminate(globalPluginHandler) # the brailleViewer should be destroyed safely before closing the window brailleViewer.destroyBrailleViewer()
def terminate(): import brailleViewer brailleViewer.destroyBrailleViewer() for instance, state in gui.SettingsDialog._instances.items(): if state is gui.SettingsDialog._DIALOG_DESTROYED_STATE: log.error( "Destroyed but not deleted instance of settings dialog exists: {!r}".format(instance) ) else: log.debug("Exiting NVDA with an open settings dialog: {!r}".format(instance)) global mainFrame # This is called after the main loop exits because WM_QUIT exits the main loop # without destroying all objects correctly and we need to support WM_QUIT. # Therefore, any request to exit should exit the main loop. safeAppExit() # #4460: We need another iteration of the main loop # so that everything (especially the TaskBarIcon) is cleaned up properly. # ProcessPendingEvents doesn't seem to work, but MainLoop does. # Because the top window gets destroyed, # MainLoop thankfully returns pretty quickly. wx.GetApp().MainLoop() mainFrame = None
def onToggleBrailleViewerCommand(self, evt): import brailleViewer if brailleViewer.isBrailleViewerActive(): brailleViewer.destroyBrailleViewer() else: brailleViewer.createBrailleViewerTool()