#1
|
|||
|
|||
Bug in vizproximity.Manager.removeSensor
When moving our code from using hotspots to vizproximity I seem to have discovered a bug in this module (both already available in Vizard4). The method vizproximity.Manager.getActiveSensors() can return sensors which have already been deleted through vizproximity.Manager.removeSensor(). Which, when you have the need to add and remove frequently, leads to accumulation of (not available) sensors in the active list of a target.
I took the liberty to check the module and found this: the update routine adds a set of sensors that are currently triggered to each target and stores this in the self._target dictionary: Code:
def update(self): """Update state of proximity sensors and trigger enter/exit events if needed""" # Don't bother checking if no targets or sensors if not (self._targets and self._sensors): return # Set of active sensors for debugging purposes activeSensors = None if self._debugRoot is not None: activeSensors = set() # Check if each target is in range of each sensor events = [] for t,active in self._targets.iteritems(): pos = t.getPosition() for s in self._sensors.iterkeys(): isInside = s.containsPoint(pos) if isInside and activeSensors is not None: activeSensors.add(s) wasInside = s in active if wasInside != isInside: if isInside: active.add(s) events.append( (ENTER_PROXIMITY_EVENT, ProximityEvent(s,t,self)) ) else: active.remove(s) events.append( (EXIT_PROXIMITY_EVENT, ProximityEvent(s,t,self)) ) : : Code:
def removeSensor(self,sensor): """Remove a proximity sensor from the manager""" try: data = self._sensors[sensor] except KeyError: return # Remove debug node of sensor if data.debug: data.debug.remove() # Remove sensor from target's active list (C) Siemens AG for active in self._targets.itervalues(): active.discard(sensor) # Remove sensor from dictionary del self._sensors[sensor] sensor.removeRemoveCallback(self.removeSensor)
__________________
21 is only half the truth. |
#2
|
|||
|
|||
Thanks for taking the time to report this bug and also find a fix!
|
#3
|
|||
|
|||
Could you please include this fix in a future release of both 4 and 5? I have multiple machines on which I run Vizard and I don't want to fix this error on all of them...
Thanks! |
#4
|
|||
|
|||
As far as I have checked, the patch is included in the final release of Vizard5.
If Vizard4 will receive another patch - I don't think so. But that's up to WorldViz, of course. Best Regards, Walter
__________________
21 is only half the truth. |
Tags |
bug, vizproximity |
Thread Tools | |
Display Modes | Rate This Thread |
|
|