diff --git a/appveyor.yml b/appveyor.yml index 7cfd77970ae..0072099bee0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -147,6 +147,12 @@ before_test: Add-AppveyorMessage "Unable to install NVDA prior to tests." } Push-AppveyorArtifact $installerLogFilePath + $crashDump = "$outputDir\nvda_crash.dmp" + if (Test-Path -Path $crashDump){ + Push-AppveyorArtifact $crashDump -FileName "nvda_install_crash.dmp" + Add-AppveyorMessage "Install process crashed" + $errorCode=1 + } if($errorCode -ne 0) { $host.SetShouldExit($errorCode) } test_script: diff --git a/source/core.py b/source/core.py index ca36a04dbf2..0bfc8dfcff8 100644 --- a/source/core.py +++ b/source/core.py @@ -111,9 +111,9 @@ def onResult(ID): def restart(disableAddons=False, debugLogging=False): """Restarts NVDA by starting a new copy.""" if globalVars.appArgs.launcher: - import wx + import gui globalVars.exitCode=3 - wx.GetApp().ExitMainLoop() + gui.safeAppExit() return import subprocess import winUser diff --git a/source/gui/__init__.py b/source/gui/__init__.py index 742e8869dcb..43b1c80b5d4 100644 --- a/source/gui/__init__.py +++ b/source/gui/__init__.py @@ -75,10 +75,6 @@ def __init__(self): self.Show() self.Hide() - def Destroy(self): - self.sysTrayIcon.Destroy() - super(MainFrame, self).Destroy() - def prePopup(self): """Prepare for a popup. This should be called before any dialog or menu which should pop up for the user. @@ -199,7 +195,7 @@ def onExitCommand(self, evt): d.Show() self.postPopup() else: - wx.GetApp().ExitMainLoop() + safeAppExit() def onNVDASettingsCommand(self,evt): self._popupSettingsDialog(NVDASettingsDialog) @@ -359,6 +355,25 @@ def onConfigProfilesCommand(self, evt): ProfilesDialog(gui.mainFrame).Show() self.postPopup() + +def safeAppExit(): + """ + Ensures the app is exited by all the top windows being destroyed + """ + + for window in wx.GetTopLevelWindows(): + if isinstance(window, wx.Dialog) and window.IsModal(): + log.info(f"ending modal {window} during exit process") + wx.CallAfter(window.EndModal, wx.ID_CLOSE_ALL) + if isinstance(window, MainFrame): + log.info(f"destroying main frame during exit process") + # the MainFrame has EVT_CLOSE bound to the ExitDialog + # which calls this function on exit, so destroy this window + wx.CallAfter(window.Destroy) + else: + log.info(f"closing window {window} during exit process") + wx.CallAfter(window.Close) + class SysTrayIcon(wx.adv.TaskBarIcon): def __init__(self, frame): @@ -527,10 +542,6 @@ def __init__(self, frame): self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.onActivate) self.Bind(wx.adv.EVT_TASKBAR_RIGHT_DOWN, self.onActivate) - def Destroy(self): - self.menu.Destroy() - super(SysTrayIcon, self).Destroy() - def onActivate(self, evt): mainFrame.prePopup() import appModules.nvda @@ -585,7 +596,7 @@ def terminate(): # 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. - wx.CallAfter(mainFrame.Destroy) + 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. @@ -712,7 +723,7 @@ def onOk(self, evt): if action >= 2 and config.isAppX: action += 1 if action == 0: - wx.GetApp().ExitMainLoop() + safeAppExit() elif action == 1: queueHandler.queueFunction(queueHandler.eventQueue,core.restart) elif action == 2: diff --git a/source/gui/installerGui.py b/source/gui/installerGui.py index db9a9576284..36a1f701b8a 100644 --- a/source/gui/installerGui.py +++ b/source/gui/installerGui.py @@ -102,7 +102,7 @@ def doInstall( winUser.SW_SHOWNORMAL ) else: - wx.GetApp().ExitMainLoop() + gui.safeAppExit() def doSilentInstall( @@ -450,7 +450,7 @@ def doCreatePortable(portableDirectory,copyUserConfig=False,silent=False,startAf return d.done() if silent: - wx.GetApp().ExitMainLoop() + gui.safeAppExit() else: # Translators: The message displayed when a portable copy of NVDA has been successfully created. # %s will be replaced with the destination directory. diff --git a/source/gui/startupDialogs.py b/source/gui/startupDialogs.py index 8830a9c1ae9..d26f7a9367a 100644 --- a/source/gui/startupDialogs.py +++ b/source/gui/startupDialogs.py @@ -193,7 +193,7 @@ def onContinueRunning(self, evt): core.doStartupDialogs() def onExit(self, evt): - wx.GetApp().ExitMainLoop() + gui.safeAppExit() @classmethod def run(cls): diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 8b0f48b88d4..7afc23131c1 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -24,6 +24,7 @@ What's New in NVDA - Updated liblouis braille translator to [3.17.0 https://github.com/liblouis/liblouis/releases/tag/v3.17.0]. (#12137) - New braille tables: Belarusian literary braille, Belarusian computer braille, Urdu grade 1, Urdu grade 2. - Support for Adobe Flash content has been removed from NVDA due to the use of Flash being actively discouraged by Adobe. (#11131) +- NVDA will exit even with windows still open, the exit process now closes all NVDA windows and dialogs (#1740) == Bug Fixes ==