defcon icon indicating copy to clipboard operation
defcon copied to clipboard

baseDict eq should happen on object id instead of object data

Open typemytype opened this issue 4 years ago • 0 comments

The problem was detected while holding notifications of anchor objects. The anchor data didnt change but the notifications was not held cause the key based on the object was already in the held notifications.

Compare BaseDict object on id not on object data, similar as other defcon objects like components, contours.

Will push a PR in a bit

import defcon

c1 = defcon.Component()
c2 = defcon.Component()
c1.baseGlyph = c2.baseGlyph = "foo"

print(c1 == c2)
print(c1 in [c2])

a1 = defcon.Anchor()
a2 = defcon.Anchor()
a1.name = a2.name = "foo"
a1.x = a2.x = 100
a1.y = a2.y = 100

print(a1 == a2)
print(a1 in [a2])

class CmpAnchor(defcon.Anchor):
    
    def __eq__(self, other):
        return id(self) == id(other)
    

a1 = CmpAnchor()
a2 = CmpAnchor()
a1.name = a2.name = "foo"
a1.x = a2.x = 100
a1.y = a2.y = 100

print(a1 == a2)
print(a1 in [a2])

typemytype avatar Feb 25 '21 19:02 typemytype