Skip to content

Commit

Permalink
Remove incorrect vmIDsToWindowHandles cache
Browse files Browse the repository at this point in the history
The vmIDsToWindowHandles cache is base on an incorrect assumption
that there is a mapping between a jvmid to a _single_ Window Handle.
This is incorrect as a Java application can have many top level
windows (each top level frame corresponds to a unique Window Handle).

The cache was introduced in 2007:

nvaccess@d4a74c7
c5d667e83b

This code was incorrect at the time, but was good enough to make things
work with Java applications that have only one top level frame.

A commit in 2010 implemented the correct way of retrieving the window
handle from a given AccessibleContext:

nvaccess@eddfb4b
4bc12582e5

This effectively removed the need of using cache, but the cache was
not removed for some reason.

The symptom of the issue is described in bug nvaccess#5732.
  • Loading branch information
rpaquay committed Feb 3, 2016
1 parent d44281d commit ef649e6
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions source/JABHandler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#javaAccessBridgeHandler.py
#javaAccessBridgeHandler.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2006-2007 NVDA Contributors <http://www.nvda-project.org/>
#This file is covered by the GNU General Public License.
Expand Down Expand Up @@ -282,7 +282,6 @@ class AccessibleKeyBindings(Structure):
#NVDA specific code

isRunning=False
vmIDsToWindowHandles={}
internalFunctionQueue=Queue.Queue(1000)
internalFunctionQueue.__name__="JABHandler.internalFunctionQueue"

Expand All @@ -297,16 +296,10 @@ def __init__(self,hwnd=None,vmID=None,accContext=None):
vmID=c_long()
accContext=JOBJECT64()
bridgeDll.getAccessibleContextFromHWND(hwnd,byref(vmID),byref(accContext))
#Record this vm ID and window handle for later use with other objects
vmIDsToWindowHandles[vmID.value]=hwnd
elif vmID and not hwnd:
hwnd=vmIDsToWindowHandles.get(vmID)
if not hwnd:
topAC=bridgeDll.getTopLevelObject(vmID,accContext)
hwnd=bridgeDll.getHWNDFromAccessibleContext(vmID,topAC)
bridgeDll.releaseJavaObject(vmID,topAC)
#Record this vm ID and window handle for later use with other objects
vmIDsToWindowHandles[vmID.value]=hwnd
topAC=bridgeDll.getTopLevelObject(vmID,accContext)
hwnd=bridgeDll.getHWNDFromAccessibleContext(vmID,topAC)
bridgeDll.releaseJavaObject(vmID,topAC)
self.hwnd=hwnd
self.vmID=vmID
self.accContext=accContext
Expand Down Expand Up @@ -642,7 +635,6 @@ def enterJavaWindow_helper(hwnd):
except:
return
vmID=vmID.value
vmIDsToWindowHandles[vmID]=hwnd
lastFocus=eventHandler.lastQueuedFocusObject
if isinstance(lastFocus,NVDAObjects.JAB.JAB) and lastFocus.windowHandle==hwnd:
return
Expand Down

0 comments on commit ef649e6

Please sign in to comment.