[Nvda-dev] commit r1881 - in trunk/source: . NVDAObjects

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Nvda-dev] commit r1881 - in trunk/source: . NVDAObjects

NVDA Subversion
Author: mdcurran
Date: Thu Apr  3 11:47:42 2008
New Revision: 1881

Log:
Some fixes to make it more impossible for the exception in keyboardHandler.internal_keyDownEvent because of it trying to get a virtualBuffer, to occure. Base NVDAObject's virtualBuffer property:  rename _virtualBufferRef to _virtualBuffer. _virtualBuffer can now be handled either as a weakref, or as None etc. When assigning to the virtualBuffer property, if the value is not None, then its wrapped in a weakref, if its None, then it just gets set as None. When retreaving the virtualBuffer property's value, if _virtualBuffer exists, its first checked to see if its a weakref, if so, then its dereferenced. If this value is not None and it is a virtualBuffer that exists in the virtualBuffer runningTable, then it is returned, else, _virtualBuffer is set to None, and None is returned. api.setFocusObject: make sure that obj.virtualBuffer gets assigned to, even if the virtualBuffer that virtualBufferHandler.update returns is just None. This stops virtualBuffers trying to be fetched after this value is set, whether or not its a valid virtualBuffer.

Modified:
   trunk/source/NVDAObjects/__init__.py
   trunk/source/api.py

Modified: trunk/source/NVDAObjects/__init__.py
==============================================================================
--- trunk/source/NVDAObjects/__init__.py (original)
+++ trunk/source/NVDAObjects/__init__.py Thu Apr  3 11:47:42 2008
@@ -383,21 +383,30 @@
  return not self.__eq__(other)
 
  def _get_virtualBuffer(self):
- if hasattr(self,'_virtualBufferRef'):
- v=self._virtualBufferRef()
+ if hasattr(self,'_virtualBuffer'):
+ v=self._virtualBuffer
+ if isinstance(v,weakref.ref):
+ v=v()
  if v and v in virtualBufferHandler.runningTable:
  return v
  else:
+ self._virtualBuffer=None
  return None
  else:
  v=virtualBufferHandler.getVirtualBuffer(self)
  if v:
- self._virtualBufferRef=weakref.ref(v)
+ self._virtualBuffer=weakref.ref(v)
  return v
 
  def _set_virtualBuffer(self,obj):
  if obj:
- self._virtualBufferRef=weakref.ref(obj)
+ self._virtualBuffer=weakref.ref(obj)
+ else: #We can't point a weakref to None, so just set the private variable to None, it can handle that
+ self._virtualBuffer=None
+
+
+
+
 
  def _get_appModule(self):
  if not hasattr(self,'_appModuleRef'):

Modified: trunk/source/api.py
==============================================================================
--- trunk/source/api.py (original)
+++ trunk/source/api.py Thu Apr  3 11:47:42 2008
@@ -111,8 +111,8 @@
  for o in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]+[globalVars.focusObject]:
  virtualBufferObject=virtualBufferHandler.update(o)
  if virtualBufferObject:
- obj.virtualBuffer=virtualBufferObject
  break
+ obj.virtualBuffer=virtualBufferObject
  if obj.virtualBuffer:
  virtualBufferHandler.reportPassThrough(obj.virtualBuffer)
  if globalVars.log.getEffectiveLevel()<=logging.INFO: