Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

holdNotifications #97

Open
typemytype opened this issue Feb 3, 2017 · 0 comments
Open

holdNotifications #97

typemytype opened this issue Feb 3, 2017 · 0 comments

Comments

@typemytype
Copy link
Member

typemytype commented Feb 3, 2017

now holdNotifications only rejects a notification if the last added notification is the same.
This does not work as expected, fe: setting a contour.dirty = True automatically send an Glyph.Changed notification as each glyph is subscribed to his contour changes.

This ends up with a stack duplicated notifications

see https://github.com/typesupply/defcon/blob/master/Lib/defcon/tools/notifications.py#L140

Should it not test if the notification is already being held?

like: if n not in self._holds[key]["notifications"]:

the only thing is that the order could be important... but also maybe not really...

from defcon import Font

class TestObserver(object):
    
    def action(self, notification):
        print notification.name

f = Font()
g = f.newGlyph("a")

p = g.getPen()
p.moveTo((100, 100))
p.lineTo((200, 200))
p.endPath()

observer = TestObserver()
g.addObserver(observer, "action", "Glyph.Changed")

g.holdNotifications()

g[0].dirty = True
g.dirty = True # this will be rejected
g[0].dirty = True # this will not be rejected but is the same as the previous one
#g.dirty = True # this will be rejected
g[0].dirty = True # this will not be rejected but is the same as the first one

for holds, items in g.dispatcher._holds.items():
    print len(items.get("notifications"))
    for notification in items.get("notifications", []):
        print "    ", notification[0]
    print 

# release 
g.releaseHeldNotifications()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant