Mercurial > code > home > repos > light9
changeset 1645:9c5e62615a63
don't let handlers pile up (workaround)
Ignore-this: c99eb0cce187fe7a49ba163431503680
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sat, 10 Jun 2017 09:14:01 +0000 |
parents | 9f7e31bf3f0c |
children | 40bd7f24cae8 |
files | light9/web/graph.coffee |
diffstat | 1 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/graph.coffee Sat Jun 10 08:38:39 2017 +0000 +++ b/light9/web/graph.coffee Sat Jun 10 09:14:01 2017 +0000 @@ -75,7 +75,11 @@ throw new Error("missing label") h = new Handler(func, label) - @handlerStack[@handlerStack.length - 1].innerHandlers.push(h) + tailChildren = @handlerStack[@handlerStack.length - 1].innerHandlers + matchingLabel = _.filter(tailChildren, ((c) -> c.label == label)).length + # ohno, something depends on some handlers getting run twice :( + if matchingLabel < 2 + tailChildren.push(h) console.time("handler #{label}") @_rerunHandler(h, null) console.timeEnd("handler #{label}") @@ -93,10 +97,20 @@ #log('done. got: ', handler.patterns) @handlerStack.pop() # handler might have no watches, in which case we could forget about it + + _logHandlerTree: -> + log('handler tree:') + prn = (h, depth) -> + indent = '' + for i in [0...depth] + indent += ' ' + log(indent + h.label) + for c in h.innerHandlers + prn(c, depth + 1) + prn(@handlers, 0) graphChanged: (patch) -> # SyncedGraph is telling us this patch just got applied to the graph. - rerunInners = (cur) => toRun = cur.innerHandlers.slice() for child in toRun @@ -188,7 +202,6 @@ if not q.graph? throw new Error("corrupt patch: #{q}") - log('graph: patch', patch) @_applyPatch(patch) @_client.sendPatch(patch) if @_client