From 7d247ee4be3713f5e583524bca44316156024ef7 Mon Sep 17 00:00:00 2001 From: Cyrille Bougot Date: Thu, 29 Aug 2024 02:58:29 +0200 Subject: [PATCH] Enable debug logging when restarting NVDA with add-ons (#17043) Fixes the initial request of #11538. Summary of the issue: When a user encounters an issue with NVDA, a dev diagnosing the issue may need to ask them a log. In this situation, the most common use case is to ask a log with add-ons disabled (to eliminate possible add-on interferences) and log level set to debug (to get the maximum information to help debugging). Though, NVDA does not provide a handy way to restart with add-ons disabled and log level set to debug. Description of user facing changes NVDA's exit dialog now provides the 4 following permanent options: "Exit" (as before) "Restart" (as before) "Restart with add-ons disabled and debug logging", replacing "Restart with add-ons disabled". This option may be used to discriminate if a bug comes from NVDA or from add-ons, and in case it comes from NVDA, help a developer to investigate and fix it. "Restart with debug logging", just renamed from "Restart with debug logging enabled". This option is useful to get a log to investigate a bug in an add-on. The non-permanent option to install pending updates remains unchanged. And the options in secure mode remain unchanged. More specifically, "Restart with add-ons disabled" remains without enabling debug logging because logging is disabled in secure mode. Description of development approach Added the RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING item in gui.exit._ExitAction enum. And removed the unneeded items of this enum to display the combo-box. More specifically, RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING and RESTART_WITH_ADDONS_DISABLED cannot coexist in the allowed values of the combo-box. Also renamed RESTART_WITH_DEBUG_LOGGING_ENABLED to RESTART_WITH_DEBUG_LOGGING so that RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING does not become a longer RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING_ENABLED; same (and more importantly) for the displayed string. Moreover, technically there is no debug logging that we can enable or disable in NVDA, but a debug level that may be set to "disabled", to "debug" or other intermediate levels. At last, "Restart with debug logging" is not named "Restart with add-ons enabled and debug logging", because the add-ons can still be disabled all individually in the add-on store. --- source/gui/exit.py | 34 +++++++++++++++++++++++++++++----- user_docs/en/changes.md | 4 ++++ user_docs/en/userGuide.md | 8 +++++++- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/source/gui/exit.py b/source/gui/exit.py index 53d95425458..e24184f871b 100644 --- a/source/gui/exit.py +++ b/source/gui/exit.py @@ -1,5 +1,5 @@ # A part of NonVisual Desktop Access (NVDA) -# Copyright (C) 2006-2023 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Mesar Hameed, Joseph Lee, +# Copyright (C) 2006-2024 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Mesar Hameed, Joseph Lee, # Thomas Stivers, Babbage B.V., Accessolutions, Julien Cochuyt, Cyrille Bougot # This file may be used under the terms of the GNU General Public License, version 2 or later. # For more details see: https://www.gnu.org/licenses/gpl-2.0.html @@ -32,6 +32,7 @@ class _ExitAction(DisplayStringEnum): EXIT = auto() RESTART = auto() + RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING_ENABLED = auto() RESTART_WITH_ADDONS_DISABLED = auto() RESTART_WITH_DEBUG_LOGGING_ENABLED = auto() INSTALL_PENDING_UPDATE = auto() @@ -43,8 +44,14 @@ def _displayStringLabels(self): self.EXIT: _("Exit"), # Translators: An option in the combo box to choose exit action. self.RESTART: _("Restart"), - # Translators: An option in the combo box to choose exit action. - self.RESTART_WITH_ADDONS_DISABLED: _("Restart with add-ons disabled"), + self.RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING_ENABLED: _( + # Translators: An option in the combo box to choose exit action. + "Restart with add-ons disabled and debug logging enabled", + ), + self.RESTART_WITH_ADDONS_DISABLED: _( + # Translators: An option in the combo box to choose exit action. + "Restart with add-ons disabled", + ), # Translators: An option in the combo box to choose exit action. self.RESTART_WITH_DEBUG_LOGGING_ENABLED: _("Restart with debug logging enabled"), # Translators: An option in the combo box to choose exit action. @@ -98,11 +105,17 @@ def __init__(self, parent): allowedActions = list(_ExitAction) # Windows Store version of NVDA does not support add-ons yet. if config.isAppX: - allowedActions.remove(_ExitAction.RESTART_WITH_ADDONS_DISABLED) + allowedActions.remove(_ExitAction.RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING_ENABLED) # Changing debug level on secure screen is not allowed. # Logging on secure screens could allow keylogging of passwords and retrieval from the SYSTEM user. if globalVars.appArgs.secure: allowedActions.remove(_ExitAction.RESTART_WITH_DEBUG_LOGGING_ENABLED) + try: + allowedActions.remove(_ExitAction.RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING_ENABLED) + except ValueError: # If already removed before + pass + else: + allowedActions.remove(_ExitAction.RESTART_WITH_ADDONS_DISABLED) # Installing updates should not happen in secure mode. if globalVars.appArgs.secure or not (updateCheck and updateCheck.isPendingUpdate()): allowedActions.remove(_ExitAction.INSTALL_PENDING_UPDATE) @@ -134,7 +147,18 @@ def onOk(self, evt): elif action == _ExitAction.RESTART: queueHandler.queueFunction(queueHandler.eventQueue, core.restart) elif action == _ExitAction.RESTART_WITH_ADDONS_DISABLED: - queueHandler.queueFunction(queueHandler.eventQueue, core.restart, disableAddons=True) + queueHandler.queueFunction( + queueHandler.eventQueue, + core.restart, + disableAddons=True, + ) + elif action == _ExitAction.RESTART_WITH_ADDONS_DISABLED_AND_DEBUG_LOGGING_ENABLED: + queueHandler.queueFunction( + queueHandler.eventQueue, + core.restart, + disableAddons=True, + debugLogging=True, + ) elif action == _ExitAction.RESTART_WITH_DEBUG_LOGGING_ENABLED: queueHandler.queueFunction(queueHandler.eventQueue, core.restart, debugLogging=True) elif action == _ExitAction.INSTALL_PENDING_UPDATE: diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index a54bf95498b..07276751878 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -8,6 +8,10 @@ * In Mozilla Firefox, NVDA will report the highlighted text when a URL containing a text fragment is visited. (#16910, @jcsteh) +### Changes + +* The exit dialog now allows you to restart NVDA with add-ons disabled and debug logging enabled simultaneously. (#11538, @CyrilleB79) + ### Bug Fixes * Native support for the Dot Pad tactile graphics device from Dot Inc as a multiline braille display. (#17007) diff --git a/user_docs/en/userGuide.md b/user_docs/en/userGuide.md index 389230d8661..b24972322e5 100644 --- a/user_docs/en/userGuide.md +++ b/user_docs/en/userGuide.md @@ -1755,7 +1755,13 @@ This option is a checkbox that, when checked, tells NVDA to automatically save t ##### Show exit options when exiting NVDA {#GeneralSettingsShowExitOptions} This option is a checkbox that allows you to choose whether or not a dialog appears when you exit NVDA that asks what action you want to perform. -When checked, a dialog will appear when you attempt to exit NVDA asking whether you want to exit, restart, restart with add-ons disabled or install pending updates (if any). +When checked, a dialog will appear when you attempt to exit NVDA, offering the following possibilities: +* exit +* restart +* restart with add-ons disabled and debug logging enabled +* restart with debug logging enabled +* install pending updates (if any). + When unchecked, NVDA will exit immediately. ##### Play sounds when starting or exiting NVDA {#GeneralSettingsPlaySounds}