Skip to content

baseDict eq should happen on object id instead of object data #343

@typemytype

Description

@typemytype

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])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions