Merge pull request #2812 from kived/refprop-setitem

prevent dispatch in ReferenceListProperty.setitem if values haven't changed
This commit is contained in:
Akshay Arora 2015-01-02 00:18:50 +05:30
commit bb79e585ef
1 changed files with 5 additions and 3 deletions

View File

@ -1225,6 +1225,7 @@ cdef class ReferenceListProperty(Property):
cpdef setitem(self, EventDispatcher obj, key, value):
cdef PropertyStorage ps = obj.__storage[self._name]
cdef bint res = False
ps.stop_event = 1
if isinstance(key, slice):
@ -1232,12 +1233,13 @@ cdef class ReferenceListProperty(Property):
for index in xrange(len(props)):
prop = props[index]
x = value[index]
prop.set(obj, x)
res = prop.set(obj, x) or res
else:
prop = ps.properties[key]
prop.set(obj, value)
res = prop.set(obj, value)
ps.stop_event = 0
self.dispatch(obj)
if res:
self.dispatch(obj)
cpdef get(self, EventDispatcher obj):
cdef PropertyStorage ps = obj.__storage[self._name]