Repository: nvaccess/nvda

Issue:
Braille viewer crashes NVDA in last alpha
I am opening this new issue so that it will be tracked better.
Following https://github.com/nvaccess/nvda/pull/11804#issuecomment-729602851 and also reproduced by myself.

### Steps to reproduce:

Open braille viewer from NVDA menu

### Actual behavior:

NVDA crashes.

### Expected behavior:

Braille viewer opens.

### System configuration
#### NVDA installed/portable/running from source:
From source
#### NVDA version:
Version : source-master-376edfc

#### Windows version:
10
#### Name and version of other software in use when reproducing the issue:

#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your computer?
Not tested.
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
2020.3 is OK
#### If addons are disabled, is your problem still occuring?
Yes
#### Did you try to run the COM registry fixing tool in NVDA menu / tools?
No


Discussion:
Probably a regression of PR #11804.
Cc @feerrenrut 

Could you post the log? I can't reproduce this with my latest master build.
Does he mean this?

Input: kb(desktop):downArrow
IO - speech.speak (07:45:33.626) - MainThread (5548):
Speaking [LangChangeCommand ('en_GB'), 'Braille viewer', 'b', '3 of 11']
IO - inputCore.InputManager.executeGesture (07:45:37.309) - winInputHook 
(1116):
Input: kb(desktop):enter
DEBUG - brailleViewer.brailleViewerGui.BrailleViewerFrame.__init__ 
(07:45:37.313) - MainThread (5548):
Starting braille viewer with 40 cells
DEBUG - gui.contextHelp.bindHelpEvent (07:45:37.313) - MainThread (5548):
Did context help binding for BrailleViewerFrame
DEBUG - fonts.importFonts (07:45:37.314) - MainThread (5548):
Loading fonts.
DEBUG - fonts.addFonts (07:45:37.314) - MainThread (5548):
Fonts to load: ['C:\\nvda extra\\fonts\\FreeMono-FixedBraille.ttf']
DEBUG - fonts.addFonts (07:45:37.314) - MainThread (5548):
Added font resource C:\nvda extra\fonts\FreeMono-FixedBraille.ttf, imported 
1 fonts.
DEBUG - brailleViewer.brailleViewerGui.BrailleViewerFrame._createControls 
(07:45:37.316) - MainThread (5548):
Initial braille label size (765, 28)
DEBUG - fonts.importFonts (07:45:37.317) - MainThread (5548):
Fonts already loaded.
DEBUG - brailleViewer.brailleViewerGui.BrailleViewerFrame._createControls 
(07:45:37.318) - MainThread (5548):
Font for braille: freemono-fixedbraille 20
DEBUG - fonts.importFonts (07:45:37.318) - MainThread (5548):
Fonts already loaded.
DEBUG - brailleViewer.brailleViewerGui.BrailleViewerFrame._createControls 
(07:45:37.319) - MainThread (5548):
Font for raw text: freemono-fixedbraille 20
CRITICAL - watchdog._crashHandler (07:45:37.371) - MainThread (5548):
NVDA crashed! Minidump written to 
C:\Users\Brian\AppData\Local\Temp\nvda.log\..\nvda_crash.dmp
INFO - watchdog._crashHandler (07:45:38.355) - MainThread (5548):
Listing stacks for Python threads:
Python stack for thread 6116 (watchdog):
  File "threading.pyc", line 890, in _bootstrap
  File "threading.pyc", line 926, in _bootstrap_inner
  File "threading.pyc", line 870, in run
  File "watchdog.pyc", line 112, in _watcher
  File "winKernel.pyc", line 228, in waitForSingleObject

Python stack for thread 3884 (Thread-1):
  File "threading.pyc", line 890, in _bootstrap
  File "threading.pyc", line 926, in _bootstrap_inner
  File "threading.pyc", line 870, in run
  File "C:\nvda 
extra\userConfig\addons\audiothemes\globalPlugins\audiothemes\unspoken\mixer.py", 
line 40, in feeder_func
    self.queue.put(block_string, block=True)
  File "queue.pyc", line 139, in put
  File "threading.pyc", line 296, in wait

Python stack for thread 5668 (Thread-2):
  File "threading.pyc", line 890, in _bootstrap
  File "threading.pyc", line 926, in _bootstrap_inner
  File "threading.pyc", line 870, in run
  File "C:\nvda 
extra\userConfig\addons\audiothemes\globalPlugins\audiothemes\unspoken\mixer.py", 
line 57, in player_func
    self.player.feed(send_string)
  File "nvwave.pyc", line 326, in feed
  File "nvwave.pyc", line 341, in _feedUnbuffered_handleErrors
  File "nvwave.pyc", line 369, in _feedUnbuffered
  File "nvwave.pyc", line 386, in sync
  File "winKernel.pyc", line 228, in waitForSingleObject

Python stack for thread 1116 (winInputHook):
  File "threading.pyc", line 890, in _bootstrap
  File "threading.pyc", line 926, in _bootstrap_inner
  File "threading.pyc", line 870, in run
  File "winInputHook.pyc", line 79, in hookThreadFunc

Python stack for thread 2768 (_UIAHandler.UIAHandler.MTAThread):
  File "threading.pyc", line 890, in _bootstrap
  File "threading.pyc", line 926, in _bootstrap_inner
  File "threading.pyc", line 870, in run
  File "_UIAHandler.pyc", line 315, in MTAThreadFunc
  File "queue.pyc", line 170, in get
  File "threading.pyc", line 296, in wait

Python stack for thread 4220 (braille._BgThread):
  File "threading.pyc", line 890, in _bootstrap
  File "threading.pyc", line 926, in _bootstrap_inner
  File "threading.pyc", line 870, in run
  File "braille.pyc", line 2188, in func

Python stack for thread 3784 (synthDrivers._espeak.BgThread):
  File "threading.pyc", line 890, in _bootstrap
  File "threading.pyc", line 926, in _bootstrap_inner
  File "synthDrivers\_espeak.pyc", line 191, in run
  File "queue.pyc", line 170, in get
  File "threading.pyc", line 296, in wait

Python stack for thread 5548 (MainThread):
  File "nvda.pyw", line 247, in <module>
  File "core.pyc", line 568, in main
  File "wx\core.pyc", line 2134, in MainLoop
  File "wx\core.pyc", line 3240, in <lambda>
  File "gui\__init__.pyc", line 158, in showGui
  File "gui\__init__.pyc", line 583, in onActivate
  File "gui\__init__.pyc", line 329, in onToggleBrailleViewerCommand
  File "brailleViewer\__init__.pyc", line 114, in createBrailleViewerTool
  File "brailleViewer\brailleViewerGui.pyc", line 315, in __init__
  File "brailleViewer\brailleViewerGui.pyc", line 393, in _createControls
  File "brailleViewer\brailleViewerGui.pyc", line 406, in 
_updateMouseOverBinding
  File "wx\core.pyc", line 1392, in _EvtHandler_Unbind
  File "wx\core.pyc", line 1461, in Unbind
  File "watchdog.pyc", line 213, in _crashHandler
  File "watchdog.pyc", line 63, in getFormattedStacksForAllThreads

INFO - watchdog._crashHandler (07:45:38.355) - MainThread (5548):
Restarting due to crash


Windows 7, no braille set up, add ons still active and portable version of 
latest Alpha.
 On the installed copy we get a dialogue about stating viewer on start up 
unticked, but no way out of the dialogue, ie no ok or anything like that.

Yes @Brian1Gaff, this was the same crash.

@feerrenrut is this log enough?
Or would you need @Brian1Gaff's dumpfile?

If the dump is needed, @Brian1Gaff, could you provide here or privately to @feerrenrut the minidump.
It should be located at:
C:\Users\Brian\AppData\Local\Temp\nvda_crash.dmp
and the file should have a date/time corresponding to today at 07:45:37 (or around)?

Else, if needed, I will be able to provide log and dumpfile tonight (UTC+01:00).

I'm not sure if I uploaded it or not. I find attaching things on github a 
bit difficult, as I can never find a button that says done or anything that 
confirms its there. If its not there, please let me know.



bglists@blueyonder.co.uk
Sent via blueyonder.
Please address personal E-mail to:-
briang1@blueyonder.co.uk, putting 'Brian Gaff'
in the display name field.
Newsgroup monitored: alt.comp.blind-users
----- Original Message ----- 
From: "Cyrille Bougot" <notifications@github.com>
To: "nvaccess/nvda" <nvda@noreply.github.com>
Cc: "Brian Gaff" <bglists@blueyonder.co.uk>; "Mention" 
<mention@noreply.github.com>
Sent: Friday, November 20, 2020 10:16 AM
Subject: Re: [nvaccess/nvda] Braille viewer crashes NVDA in last alpha 
(#11846)


> Yes @Brian1Gaff, this was the same crash.
>
> @feerrenrut is this log enough?
> Or would you need @Brian1Gaff's dumpfile?
>
> If the dump is needed, @Brian1Gaff, could you provide here or privately to 
> @feerrenrut the minidump.
> It should be located at:
> C:\Users\Brian\AppData\Local\Temp\nvda_crash.dmp
> and the file should have a date/time corresponding to today at 07:45:37 
> (or around)?
>
> Else, if needed, I will be able to provide log and dumpfile tonight 
> (UTC+01:00).
>
>
> -- 
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub:
> https://github.com/nvaccess/nvda/issues/11846#issuecomment-731079228 

To insert a file, you need to comment on GitHub, not to reply via e-mail.
* Go in the field to write a new comment
* Press tab to focus on a button labeled "Attach an image Attach files by dragging & dropping, selecting or pasting them. Styling with Markdown is supported"
* Press this button
* Select the file and press "Open"
  Then the focus turns back to the comment field.
* After a few seconds (time required for the upload), press up arrow
  You will land on a markdown link syntax. That's your file, do not delete.

You may write something else in your comment (be careful not to write anything in the middle of the file link !). And then send it by pressing the "Comment" button (reachable 4 tabs after the edit field)



* 




Hi Reef

Here are the log and the dumpfile:
[nvda.log](https://github.com/nvaccess/nvda/files/5576038/nvda.log)
[nvda_crash.zip](https://github.com/nvaccess/nvda/files/5576044/nvda_crash.zip)

The issue is 100% reproducible on my side.

These files have been generated in the following conditions/configuration:
* No Braille display attached
* Braille display setting set to 'Automatic'
* NVDA Version: source-master-53cecfd (today's alpha)
* Run from source
* No add-on
* Windows 10 2004 (64-bit) build 19041.388


Alpha-21386 can also reproduce this problem.
The following are the logs and dump files.

[nvda_crash.zip](https://github.com/nvaccess/nvda/files/5576849/nvda_crash.zip)

[nvda-old.log](https://github.com/nvaccess/nvda/files/5576844/nvda-old.log)

I did that online, but could not find the button to actually finish the job.
 Brian


Resolving patch:
diff --git a/source/brailleViewer/brailleViewerGui.py b/source/brailleViewer/brailleViewerGui.py
--- a/source/brailleViewer/brailleViewerGui.py
+++ b/source/brailleViewer/brailleViewerGui.py
@@ -261,6 +261,8 @@ class BrailleViewerFrame(
 	_brailleOutputLastSet: str
 	_brailleOutput: wx.TextCtrl
 	_shouldShowOnStartupCheckBox: wx.CheckBox
+	#: True if _mouseOver has been bound to mouse moved events.
+	_mouseMotionBound: bool = False
 
 	def __init__(self, numCells, onDestroyed):
 		log.debug(f"Starting braille viewer with {numCells} cells")
@@ -402,11 +404,13 @@ def _onShouldHoverRouteToCellCheckBoxChanged(self, evt: wx.CommandEvent):
 		self._updateMouseOverBinding(evt.IsChecked())
 
 	def _updateMouseOverBinding(self, shouldReceiveMouseMotion: bool):
-		if not shouldReceiveMouseMotion:
+		if not shouldReceiveMouseMotion and self._mouseMotionBound:
 			self._brailleOutput.Unbind(wx.EVT_MOTION, source=None, handler=self._mouseOver)
+			self._mouseMotionBound = False
 			self._hoverTracker.cancelPendingHover()
 		else:
 			self._brailleOutput.Bind(wx.EVT_MOTION, handler=self._mouseOver)
+			self._mouseMotionBound = True
 
 	def _mouseOver(self, unused: wx.MouseEvent):
 		if _shouldDoHover():


Test patch: